From e9fc4c1c0640cf21a85d4798aac20323100eac68 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 25 Mar 2015 08:03:23 +0100 Subject: Fix build on FreeBSD --- src/print_disk_info.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/print_disk_info.c b/src/print_disk_info.c index b9047e5..69d7b8c 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -11,6 +10,8 @@ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (__OpenBSD__) || defined(__DragonFly__) #include #include +#else +#include #endif #include #include -- cgit v1.2.3 From eaf5d6bf801baa6169d388b910a75f8108499239 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 25 Mar 2015 08:13:47 +0100 Subject: print_volume: don’t return, complete the buffer first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow the changed done for Linux on f0cd726b --- src/print_volume.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/print_volume.c b/src/print_volume.c index ef1c913..bc469f3 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -139,16 +140,22 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * else mixerpath = defaultmixer; - if ((mixfd = open(mixerpath, O_RDWR)) < 0) - return; + if ((mixfd = open(mixerpath, O_RDWR)) < 0) { + warn("OSS: Cannot open mixer"); + goto out; + } if (mixer_idx > 0) free(mixerpath); - if (ioctl(mixfd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) - return; - if (ioctl(mixfd, MIXER_READ(0), &vol) == -1) - return; + if (ioctl(mixfd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) { + warn("OSS: Cannot read mixer information"); + goto out; + } + if (ioctl(mixfd, MIXER_READ(0), &vol) == -1) { + warn("OSS: Cannot read mixer information"); + goto out; + } if (((vol & 0x7f) == 0) && (((vol >> 8) & 0x7f) == 0)) { START_COLOR("color_degraded"); -- cgit v1.2.3 From 0b882f36b55a0e45506d33d60e343ec9a492fbb4 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 25 Mar 2015 08:18:00 +0100 Subject: print_eth_info: fix warnings on FreeBSD --- src/print_eth_info.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/print_eth_info.c b/src/print_eth_info.c index af5a757..06a1613 100644 --- a/src/print_eth_info.c +++ b/src/print_eth_info.c @@ -49,11 +49,13 @@ static int print_eth_speed(char *outwalk, const char *interface) { } else return sprintf(outwalk, "?"); #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - char *ethspeed; + const char *ethspeed; struct ifmediareq ifm; (void)memset(&ifm, 0, sizeof(ifm)); (void)strncpy(ifm.ifm_name, interface, sizeof(ifm.ifm_name)); - int ret = ioctl(general_socket, SIOCGIFMEDIA, (caddr_t)&ifm); + if (ioctl(general_socket, SIOCGIFMEDIA, (caddr_t)&ifm) < 0) { + return sprintf(outwalk, "?"); + } /* Get the description of the media type, partially taken from * FreeBSD's ifconfig */ -- cgit v1.2.3 From c9dc67e0542a0f540b014e8b2607bfc269433951 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Wed, 25 Mar 2015 08:19:13 +0100 Subject: print_cpu_usage: Fix warnings on non linux Move linux variable under LINUX boundaries --- src/print_cpu_usage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/print_cpu_usage.c b/src/print_cpu_usage.c index 68437b3..2c59f69 100644 --- a/src/print_cpu_usage.c +++ b/src/print_cpu_usage.c @@ -40,12 +40,12 @@ static int prev_idle = 0; void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format) { const char *walk; char *outwalk = buffer; - char buf[1024]; int curr_user = 0, curr_nice = 0, curr_system = 0, curr_idle = 0, curr_total; int diff_idle, diff_total, diff_usage; #if defined(LINUX) static char statpath[512]; + char buf[1024]; strcpy(statpath, "/proc/stat"); if (!slurp(statpath, buf, sizeof(buf)) || sscanf(buf, "cpu %d %d %d %d", &curr_user, &curr_nice, &curr_system, &curr_idle) != 4) -- cgit v1.2.3