summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-11-18 00:07:14 +0000
committerMatt Turner <mattst88@gmail.com>2008-11-18 00:07:14 +0000
commit57d728301cd1828f4597624437df4355385f3d05 (patch)
treea54aed8bdf74c40c1dd31599ab0012318cac76e3
parent2adbcbb2ff1c89ab345eeb2177f15f9b355766f8 (diff)
Retab hardware.c
git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@81 0d43b9a7-5ab2-4d7b-af9d-f64450cef757
-rw-r--r--hardware.c68
1 files 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);
}