OSDN Git Service

Misc
authorwifiextender <router@archlinux.info>
Mon, 22 Aug 2016 06:02:28 +0000 (08:02 +0200)
committerwifiextender <router@archlinux.info>
Mon, 22 Aug 2016 06:02:28 +0000 (08:02 +0200)
src/common.c
src/cpu.c
src/freebsd_functions.c
src/linux_functions.c
src/net.c
src/sound.c

index 9b15618..2295d8d 100644 (file)
@@ -213,7 +213,7 @@ get_packs(char *str1) {
 
 #endif
 
-  FILL_ARR(str1, "%"PRIuFAST16, packages);
+  FILL_ARR(str1, UFINT, packages);
 }
 
 
@@ -305,7 +305,8 @@ get_fans(char *str1) {
   bool found_fans = true;
   char tempstr[VLA], buffer[VLA];
   char *all_fans = buffer;
-  uint_fast16_t x = 0, y = 0, z = 0, rpm[21];
+  uint8_t x = 0, y = 0, z = 0;
+  uint_fast16_t rpm[21];
 
 #if defined(__linux__)
   FILE *fp;
index 4f74e11..3306229 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -39,8 +39,9 @@
 void 
 get_cpu(char *str1) {
   static uintmax_t previous_total = 0, previous_idle = 0;
-  uintmax_t x, percent, diff_total, diff_idle, cpu_active[LOOP_ITERZ];
-  uintmax_t total = 0;
+  uintmax_t total = 0, percent = 0, diff_total = 0, diff_idle = 0;
+  uintmax_t cpu_active[LOOP_ITERZ];
+  uint8_t x = 0;
 
   memset(cpu_active, 0, sizeof(cpu_active));
 
@@ -92,8 +93,8 @@ get_cpu(char *str1) {
 void
 get_cores_load(char *str1) {
   static uintmax_t previous_total[MAX_CORES], previous_idle[MAX_CORES];
-  static uintmax_t test_flag = 0;
-  uintmax_t x = 0, y = 0, z = 0;
+  static uint8_t test_flag = 0;
+  uint8_t x = 0, y = 0, z = 0;
   uintmax_t percent[MAX_CORES], diff_total[MAX_CORES], core_active[MAX_CORES][LOOP_ITERZ];
   uintmax_t diff_idle[MAX_CORES], total[MAX_CORES];
   char buf[VLA], temp[VLA];
@@ -126,7 +127,7 @@ get_cores_load(char *str1) {
     exit_with_err(ERR, "reached /proc/stat EOF");
   }
 
-  for (x = 0; x < MAX_CORES; x++) {
+  for (x = 0; x < MAX_CORES; x++, z++) {
     if (NULL == fgets(buf, VLA, fp)) {
       fclose(fp);
       exit_with_err(ERR, "reached /proc/stat EOF");
@@ -146,7 +147,6 @@ get_cores_load(char *str1) {
   }
   fclose(fp);
 
-  z = x;
   for (x = 0; x < z; x++) {
 
 #else /* FreeBSD */
@@ -176,7 +176,6 @@ get_cores_load(char *str1) {
 
     GLUE2(all, FMT_UINT"%% ", percent[x]);
   }
-
   test_flag = 1;
 
   FILL_STR_ARR(1, str1, temp);
index 1cb0e16..565da07 100644 (file)
@@ -179,7 +179,7 @@ get_statio(char *str1, char *str2) {
   struct statinfo stats;
   struct device_selection *dev_select = NULL;
   struct devstat *d = NULL;
-  long select_generation = 0;
+  long int select_generation = 0;
   int x = 0, num_devices = 0, num_selected = 0, num_selections = 0;
 
   FILL_STR_ARR(1, str1, "Null");
index ad460d8..7d094c6 100644 (file)
@@ -107,7 +107,7 @@ void
 get_voltage(char *str1) {
   float voltage[4];
   FILE *fp;
-  uint_fast16_t x = 0;
+  uint8_t x = 0;
 
   const char *voltage_files[] = {
     VOLTAGE_FILE("0"),
index 36de174..99dea30 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -211,11 +211,9 @@ void
 get_ip_lookup(char *str1, char *str2) {
 #if WITH_NET == 1
 
-  struct addrinfo *rp = NULL, *result = NULL;
-  struct addrinfo hints;
+  struct addrinfo *rp = NULL, *result = NULL, hints;
   void *temp_void = NULL;
   char temp[VLA];
-  int err = 0;
 
   memset(&hints, 0, sizeof(hints));
 
@@ -224,8 +222,7 @@ get_ip_lookup(char *str1, char *str2) {
   hints.ai_flags = 0;
   hints.ai_protocol = 0; /* udp | tcp */
 
-  err = getaddrinfo(str2, NULL, &hints, &result);
-  if (0 != err) {
+  if (0 != (getaddrinfo(str2, NULL, &hints, &result))) {
     FUNC_FAILED("getaddrinfo()");
   }
 
@@ -303,7 +300,7 @@ get_nic_info2(char *str1, char *str2, unsigned char num) {
   }
   snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", str2);
 
-  if (0 < (ioctl(sock, SIOCETHTOOL, &ifr))) {
+  if (0 != (ioctl(sock, SIOCETHTOOL, &ifr))) {
     return;
   }
 
@@ -430,14 +427,11 @@ get_nic_info(char *str1, char *str2) {
 
   struct rt_msghdr *rtm = NULL;
   struct sockaddr *sa = NULL, *addrs[RTAX_MAX];
-  char *buf = NULL, *next = NULL, *lim = NULL;
-  char temp[VLA];
+  char *buf = NULL, *next = NULL, *lim = NULL, temp[VLA];
   uint8_t x = 0;
   size_t needed;
   void *temp_void = NULL;
 
-  FILL_STR_ARR(1, str1, "Null");
-
   /* No, it's not Men In Black acronym */
   int mib[] = { CTL_NET, PF_ROUTE, 0, 0, NET_RT_DUMP, 0 };
   if (0 != (sysctl(mib, 6, NULL, &needed, NULL, 0))) {
index ff3a467..31eac63 100644 (file)
@@ -46,7 +46,7 @@ get_volume(char *str1) {
   snd_mixer_t *handle = NULL;
   snd_mixer_elem_t *elem = NULL;
   snd_mixer_selem_id_t *s_elem = NULL;
-  long int vol, max, min, percent;
+  long int vol = 0L, max = 0L, min = 0L, percent = 0L;
 
   if (0 != (snd_mixer_open(&handle, 0))) {
     FUNC_FAILED("alsa");
@@ -130,7 +130,7 @@ get_song(char *str1, unsigned char num) {
 #if defined (HAVE_MPD_CLIENT_H)
 
   struct mpd_connection *conn = NULL;
-  struct mpd_song *song;
+  struct mpd_song *song = NULL;
 
   if (NULL == (conn = mpd_connection_new(NULL, 0, 0))) {
     return;