From 4bf02973b67f5409fd975e620e33751a4aa4f8fb Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Thu, 10 Jul 2014 11:53:47 -0600 Subject: cleanup t work on armv7 board --- loadavg.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/loadavg.cc b/loadavg.cc index 2b6c94b..311649c 100644 --- a/loadavg.cc +++ b/loadavg.cc @@ -120,7 +120,10 @@ main(int argc, char *argv[]) struct utsname utsname; memset(&utsname, 0, sizeof(struct utsname)); - + + char *arch = 0; + cpuinfo(&arch); + while (1) { DMUCS_DEBUG((stderr, "doing Sopen with %s, %s\n", serverName.str().c_str(), clientPortStr.str().c_str())); @@ -134,9 +137,7 @@ main(int argc, char *argv[]) } // Send initialization msg - char *arch = 0; - cpuinfo(&arch); - if (*utsname.machine == 0) { + if (utsname.machine[0] == 0) { uname(&utsname); std::string clientReqStr = "host " + std::string(inet_ntoa(in)) + " " + utsname.machine + "-" + arch; @@ -229,16 +230,14 @@ cpuinfo(char **arch) const char *ipat = "microcode"; bool hit = false; while (fgets(buf, sizeof(buf), cpuinfo) != NULL) { - if (strncmp(ipat, buf, sizeof(ipat)) == 0) { - hit = true; - } - if (strncmp(armpat, buf, sizeof(armpat)) == 0) { + if ((strncmp(ipat, buf, 8) == 0) + || (strncmp(armpat, buf, 8) == 0)) { hit = true; } if (hit) { - char *start = ::strchr(buf, ' '); - char *end = ::strchr(buf, '\n'); + char *start = ::strrchr(buf, ' '); + char *end = ::strrchr(buf, '\n'); ::strncpy(*arch, start+1, end-start-1); fclose(cpuinfo); return *arch; -- cgit v1.2.3