aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2019-12-11 05:12:36 -0800
committerGarrett D'Amore <garrett@damore.org>2019-12-11 05:12:36 -0800
commit5c0f08087429e7a89c97742e4a4b146688442a04 (patch)
treeb09dd481be3389d7321d3198a86efc9919216f3f /tools
parent52f5eb316f826c5c5be13c35f24f809d6d5efce4 (diff)
downloadnng-5c0f08087429e7a89c97742e4a4b146688442a04.tar.gz
nng-5c0f08087429e7a89c97742e4a4b146688442a04.tar.bz2
nng-5c0f08087429e7a89c97742e4a4b146688442a04.zip
Address complaints found by lgtm.com.
Diffstat (limited to 'tools')
-rw-r--r--tools/nngcat/nngcat.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/nngcat/nngcat.c b/tools/nngcat/nngcat.c
index 1866e8f7..ab891830 100644
--- a/tools/nngcat/nngcat.c
+++ b/tools/nngcat/nngcat.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -309,7 +309,7 @@ static void
loadfile(const char *path, void **datap, size_t *lenp)
{
FILE * f;
- char * data;
+ char * fdata;
size_t len;
if ((f = fopen(path, "r")) == NULL) {
@@ -320,16 +320,16 @@ loadfile(const char *path, void **datap, size_t *lenp)
}
len = ftell(f);
(void) fseek(f, 0, SEEK_SET);
- if ((data = malloc(len + 1)) == NULL) {
+ if ((fdata = malloc(len + 1)) == NULL) {
fatal("Out of memory.");
}
- data[len] = '\0';
+ fdata[len] = '\0';
- if (fread(data, 1, len, f) != len) {
+ if (fread(fdata, 1, len, f) != len) {
fatal("Read file %s failed: %s", path, strerror(errno));
}
fclose(f);
- *datap = data;
+ *datap = fdata;
*lenp = len;
}
@@ -860,6 +860,8 @@ main(int ac, char **av)
case NNG_ENOARG:
fatal("Option %s requires argument.", av[idx]);
break;
+ default:
+ break;
}
if (addrs == NULL) {
@@ -889,7 +891,7 @@ main(int ac, char **av)
}
if (proto == OPT_SUB0) {
if (topics == NULL) {
- topicend = addtopic(topicend, ""); // subscribe to all
+ (void) addtopic(topicend, ""); // subscribe to all
}
} else {
if (topics != NULL) {
@@ -940,6 +942,9 @@ main(int ac, char **av)
"--file or --data.");
}
break;
+ default:
+ // Will be caught in next switch statement.
+ break;
}
switch (proto) {