OSDN Git Service

Rename some manifest constants
authora <a@b.c>
Sat, 31 Mar 2018 12:31:27 +0000 (14:31 +0200)
committera <a@b.c>
Sat, 31 Mar 2018 12:31:27 +0000 (14:31 +0200)
src/common.c
src/cpu.c
src/include/functions_constants.h
src/linux_functions.c
src/net.c
src/options.c
src/smart.c
src/sound.c

index f0ad295..2aae2cb 100644 (file)
@@ -71,7 +71,7 @@ get_temp(const char *str1, char *str2) {
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, str1, SCAN_ULINT, &temp);
+  OPEN_FP(fp, str1, SCAN_ULINT, &temp);
 #pragma GCC diagnostic pop
 
   if (99999 < temp) { /* > 99C */
@@ -427,7 +427,7 @@ get_fans(char *str1) {
 #pragma GCC diagnostic ignored "-Wunused-result"
     CHECK_FSCANF(fp, SCAN_UFINT, &rpm[z]);
 #pragma GCC diagnostic pop
-    CLOSE_X(fp);
+    CLOSE_FP(fp);
   }
 
 #else
@@ -486,12 +486,12 @@ get_dvd(char *str1) {
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, DVD_VEND, "%s", vendor);
+  OPEN_FP(fp, DVD_VEND, "%s", vendor);
 #pragma GCC diagnostic pop
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, DVD_MODEL, "%s", model);
+  OPEN_FP(fp, DVD_MODEL, "%s", model);
 #pragma GCC diagnostic pop
 
   FILL_STR_ARR(2, str1, vendor, model);
@@ -508,7 +508,7 @@ get_loadavg(char *str1) {
   memset(up, 0, sizeof(up));
 
   if (-1 == (getloadavg(up, 3))) {
-       FUNC_FAILED("getloadavg()");
+    FUNC_FAILED("getloadavg()");
   }
   FILL_ARR(str1, "%.2f %.2f %.2f",
     (float)up[0], (float)up[1], (float)up[2]);
index e3c38e9..a4c2109 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -62,11 +62,11 @@ get_cpu(char *str1) {
     &cpu_active[0], &cpu_active[1], &cpu_active[2], &cpu_active[3],
     &cpu_active[4], &cpu_active[5], &cpu_active[6], &cpu_active[7],
     &cpu_active[8], &cpu_active[9]))) {
-      CLOSE_X(fp);
+      CLOSE_FP(fp);
       exit_with_err(ERR, "Upgrade to a newer kernel");
   }
 #pragma GCC diagnostic pop
-  CLOSE_X(fp);
+  CLOSE_FP(fp);
 #endif /* __linux__ */
 
   for (x = 0; x < LOOP_ITERZ; x++) {
@@ -133,13 +133,13 @@ get_cores_load(char *str1) {
   CHECK_FP(fp);
 
   if (NULL == (fgets(buf, VLA-1, fp))) {
-    CLOSE_X(fp);
+    CLOSE_FP(fp);
     exit_with_err(ERR, "reached /proc/stat EOF");
   }
 
   for (x = 0; x < MAX_CORES; x++, z++) {
     if (NULL == (fgets(buf, VLA-1, fp))) {
-      CLOSE_X(fp);
+      CLOSE_FP(fp);
       exit_with_err(ERR, "reached /proc/stat EOF");
     }
 
@@ -151,11 +151,11 @@ get_cores_load(char *str1) {
       &core_active[x][0], &core_active[x][1], &core_active[x][2], &core_active[x][3],
       &core_active[x][4], &core_active[x][5], &core_active[x][6], &core_active[x][7],
       &core_active[x][8], &core_active[x][9]))) {
-        CLOSE_X(fp);
+        CLOSE_FP(fp);
         exit_with_err(ERR, "Upgrade to a newer kernel");
     }
   }
-  CLOSE_X(fp);
+  CLOSE_FP(fp);
 
   for (x = 0; x < z; x++) {
 
index dac4e58..0dd2a26 100644 (file)
     exit_with_err(ERR, CANNOT_OPEN_FP); \
   }
 
-#define CLOSE_X(fp) \
+#define CLOSE_FP(fp) \
   if (EOF == (fclose(fp))) { \
     exit_with_err(ERR, CANNOT_CLOSE); \
   }
 
-#define OPEN_X(fp, x, y, z) \
+#define OPEN_FP(fp, x, y, z) \
   if (NULL == (fp = fopen(x, "r"))) { \
     exit_with_err(CANNOT_OPEN, x); \
   } \
   CHECK_FSCANF(fp, y, z); \
-  CLOSE_X(fp);
+  CLOSE_FP(fp);
 
 #define CHECK_POPEN(fp, x, packs) \
   if (NULL == (fp = popen(x, "r"))) { \
index eefd65d..1dfccaf 100644 (file)
@@ -87,7 +87,7 @@ get_ssd_model(char *str1, char *str2) {
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, model, "%[^\n]", model);
+  OPEN_FP(fp, model, "%[^\n]", model);
 #pragma GCC diagnostic pop
 
   FILL_STR_ARR(1, str1, model);
@@ -269,7 +269,7 @@ get_voltage(char *str1) {
 #pragma GCC diagnostic ignored "-Wunused-result"
     CHECK_FSCANF(fp, "%f", &voltage[x]);
 #pragma GCC diagnostic pop
-    CLOSE_X(fp);
+    CLOSE_FP(fp);
 
     voltage[x] /= 1000.0f;
   }
@@ -298,12 +298,12 @@ get_mobo(char *str1) {
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, MOBO_VENDOR, "%s", vendor);
+  OPEN_FP(fp, MOBO_VENDOR, "%s", vendor);
 #pragma GCC diagnostic pop
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, MOBO_NAME, "%s", name);
+  OPEN_FP(fp, MOBO_NAME, "%s", name);
 #pragma GCC diagnostic pop
 
   FILL_STR_ARR(2, str1, vendor, name);
@@ -326,11 +326,11 @@ get_statio(char *str1, char *str2) {
   if (EOF == (fscanf(fp, FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT FMT_UINT,
     &statio[0], &statio[1], &statio[2], &statio[3],
     &statio[4], &statio[5], &statio[6]))) {
-      CLOSE_X(fp);
+      CLOSE_FP(fp);
       exit_with_err(ERR, "reading the stat file failed");
   }
 #pragma GCC diagnostic pop
-  CLOSE_X(fp);
+  CLOSE_FP(fp);
 
   FILL_ARR(str1, "Read " FMT_UINT " MB, Written " FMT_UINT " MB",
     BYTES_TO_MB(statio[2]), BYTES_TO_MB(statio[6]));
@@ -361,13 +361,13 @@ get_battery(char *str1) {
 #pragma GCC diagnostic ignored "-Wunused-result"
   CHECK_FSCANF(fp, FMT_UINT, &total);
 #pragma GCC diagnostic pop
-  CLOSE_X(fp);
+  CLOSE_FP(fp);
 
   BATTERY_USED(temp, num);
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, temp, FMT_UINT, &used);
+  OPEN_FP(fp, temp, FMT_UINT, &used);
 #pragma GCC diagnostic pop
 
   FILL_UINT_ARR(str1,
index 1f4cf6b..f5b5ebe 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -384,14 +384,14 @@ get_nic_info(char *str1, char *str2) {
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, temp, SCAN_UINTX, &vendor); /* hex */
+  OPEN_FP(fp, temp, SCAN_UINTX, &vendor); /* hex */
 #pragma GCC diagnostic pop
 
   NIC_MODEL(temp, str2);
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-result"
-  OPEN_X(fp, temp, SCAN_UINTX, &model); /* hex */
+  OPEN_FP(fp, temp, SCAN_UINTX, &model); /* hex */
 #pragma GCC diagnostic pop
 
   pacc = pci_alloc();
index 6d7e5f5..bea66ab 100644 (file)
@@ -491,7 +491,7 @@ parse_konf(char *combined) {
 
   while (NULL != (fgets(buf, 99, fp))) {
     if (EOF == (sscanf(buf, "%s", temp))) {
-      CLOSE_X(fp);
+      CLOSE_FP(fp);
       exit_with_err(ERR, "empty line(s) detected.");
     }
     ptr = temp;
@@ -501,5 +501,5 @@ parse_konf(char *combined) {
     ello[1] = ptr;
     argp_parse(&arg_parser, 2, ello, ARGP_IN_ORDER, NULL, &arguments);
   }
-  CLOSE_X(fp);
+  CLOSE_FP(fp);
 }
index 263bbca..685948e 100644 (file)
@@ -196,7 +196,7 @@ get_drivetemp(char *str1) {
 #pragma GCC diagnostic ignored "-Wunused-result"
   CHECK_FSCANF(fp, SCAN_UFINT, &temp);
 #pragma GCC diagnostic pop
-  CLOSE_X(fp);
+  CLOSE_FP(fp);
 
   FILL_ARR(str1, UFINT, temp);
 }
index 14569d5..f54befa 100644 (file)
@@ -207,6 +207,8 @@ get_song(char *str1, int8_t num) {
   const char *tagz[] = { "artist", "title", "album", "date" };
   const char *idx_tagz = ((6 != num) ? tagz[num-2] : "ohsnap");
 
+  FILL_STR_ARR(1, str1, "Null");
+
   if (NULL == (fp = popen("cmus-remote -Q 2> /dev/null", "r"))) {
     return;
   }