From 57d728301cd1828f4597624437df4355385f3d05 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 18 Nov 2008 00:07:14 +0000 Subject: Retab hardware.c git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@81 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- hardware.c | 68 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/hardware.c b/hardware.c index 390b8ec..dc29355 100644 --- a/hardware.c +++ b/hardware.c @@ -12,11 +12,11 @@ ** Removes a trailing newline character if present */ static void removeNewLine(char * s) { - int len = strlen(s); - - if(len > 0 && s[len - 1] == '\n') { - s[len - 1] = '\0'; - } + int len = strlen(s); + + if(len > 0 && s[len - 1] == '\n') { + s[len - 1] = '\0'; + } } /*************** @@ -26,21 +26,21 @@ static void removeNewLine(char * s) { ** The pointer result must point to a pre-allocated array of at least BUF_SIZ */ static void runCommand (const char *command, char *result) { - FILE * pipe; - - pipe = popen(command, "r"); - if(pipe == NULL) { - /* command failed */ - result[0] = '\0'; - } else { - if(NULL == fgets(result, BUF_SIZ, pipe)) { - /* command failed */ - result[0] = '\0'; - } - pclose(pipe); - } + FILE * pipe; - removeNewLine(result); + pipe = popen(command, "r"); + if(pipe == NULL) { + /* command failed */ + result[0] = '\0'; + } else { + if(NULL == fgets(result, BUF_SIZ, pipe)) { + /* command failed */ + result[0] = '\0'; + } + pclose(pipe); + } + + removeNewLine(result); } /******************** @@ -82,22 +82,22 @@ static void readProcCpuInfo (char *model, char *cache) { */ void hardware(void) { - char os[BUF_SIZ]; - char model[BUF_SIZ]; - char cache[BUF_SIZ]; - const char os_command[] = "uname -s -r"; + char os[BUF_SIZ]; + char model[BUF_SIZ]; + char cache[BUF_SIZ]; + const char os_command[] = "uname -s -r"; #ifdef NO_UNAME - os[0] = '\0'; + os[0] = '\0'; #else - runCommand(os_command, os); + runCommand(os_command, os); #endif - if(NULL != strstr(os, "Linux")) { - readProcCpuInfo (model, cache); - } else { - model[0] = '\0'; - cache[0] = '\0'; - } - printf("CPU : %s\n", model); - printf("L2 Cache : %s\n", cache); - printf("OS : %s\n", os); + if(NULL != strstr(os, "Linux")) { + readProcCpuInfo (model, cache); + } else { + model[0] = '\0'; + cache[0] = '\0'; + } + printf("CPU : %s\n", model); + printf("L2 Cache : %s\n", cache); + printf("OS : %s\n", os); } -- cgit v1.2.3