X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fserial.c;h=2b8653703d75ce5d40045268a2761134e56f7eaf;hb=711f5b6c86f51061c21bedcaa46214a01de0125c;hp=5057fd3ad8342f871f3820a425294a52a93722b8;hpb=96b920e6b7bf70560eb95c911202afbeaab2b965;p=collectd.git diff --git a/src/serial.c b/src/serial.c index 5057fd3a..2b865370 100644 --- a/src/serial.c +++ b/src/serial.c @@ -52,15 +52,15 @@ static int serial_read(void) { /* there are a variety of names for the serial device */ if ((fh = fopen("/proc/tty/driver/serial", "r")) == NULL && (fh = fopen("/proc/tty/driver/ttyS", "r")) == NULL) { - char errbuf[1024]; - WARNING("serial: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf))); - return (-1); + WARNING("serial: fopen: %s", STRERRNO); + return -1; } while (fgets(buffer, sizeof(buffer), fh) != NULL) { derive_t rx = 0; derive_t tx = 0; - _Bool have_rx = 0, have_tx = 0; + bool have_rx = false; + bool have_tx = false; size_t len; char *fields[16]; @@ -79,7 +79,7 @@ static int serial_read(void) { continue; if (fields[0][len - 1] != ':') continue; - fields[0][len - 1] = 0; + fields[0][len - 1] = '\0'; for (int i = 1; i < numfields; i++) { len = strlen(fields[i]); @@ -88,10 +88,10 @@ static int serial_read(void) { if (strncmp(fields[i], "tx:", 3) == 0) { if (strtoderive(fields[i] + 3, &tx) == 0) - have_tx = 1; + have_tx = true; } else if (strncmp(fields[i], "rx:", 3) == 0) { if (strtoderive(fields[i] + 3, &rx) == 0) - have_rx = 1; + have_rx = true; } } @@ -100,7 +100,7 @@ static int serial_read(void) { } fclose(fh); - return (0); + return 0; } /* int serial_read */ void module_register(void) {