aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2015-08-20 10:00:28 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2015-08-20 10:00:28 -0400
commit5c0edb3435a07372bf89ef19e9730066aecc6b8c (patch)
tree062b9bc20a9d8f9ee9be39ce30638ca0f0266cf0 /src/lib
parenttesting (diff)
parentCompile with -W -Wall -Werror (diff)
downloadfirejail-5c0edb3435a07372bf89ef19e9730066aecc6b8c.tar.gz
firejail-5c0edb3435a07372bf89ef19e9730066aecc6b8c.tar.zst
firejail-5c0edb3435a07372bf89ef19e9730066aecc6b8c.zip
Merge pull request #35 from pmillerchip/warnings-cleanup
Compile with -W -Wall -Werror
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Makefile.in2
-rw-r--r--src/lib/libnetlink.c16
-rw-r--r--src/lib/pid.c20
3 files changed, 22 insertions, 16 deletions
diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in
index 6e6be1910..3d9d1d7e2 100644
--- a/src/lib/Makefile.in
+++ b/src/lib/Makefile.in
@@ -6,7 +6,7 @@ H_FILE_LIST = $(wildcard *.[h])
6C_FILE_LIST = $(wildcard *.c) 6C_FILE_LIST = $(wildcard *.c)
7OBJS = $(C_FILE_LIST:.c=.o) 7OBJS = $(C_FILE_LIST:.c=.o)
8BINOBJS = $(foreach file, $(OBJS), $file) 8BINOBJS = $(foreach file, $(OBJS), $file)
9CFLAGS += -ggdb -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security 9CFLAGS += -ggdb -W -Wall -Werror -O2 -DVERSION='"$(VERSION)"' -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security
10LDFLAGS:=-pic -Wl,-z,relro -Wl,-z,now 10LDFLAGS:=-pic -Wl,-z,relro -Wl,-z,now
11 11
12all: $(OBJS) 12all: $(OBJS)
diff --git a/src/lib/libnetlink.c b/src/lib/libnetlink.c
index 264632a01..40fb099f7 100644
--- a/src/lib/libnetlink.c
+++ b/src/lib/libnetlink.c
@@ -363,7 +363,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
363 fprintf(stderr, "sender address length == %d\n", msg.msg_namelen); 363 fprintf(stderr, "sender address length == %d\n", msg.msg_namelen);
364 exit(1); 364 exit(1);
365 } 365 }
366 for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { 366 for (h = (struct nlmsghdr*)buf; status >= (int)sizeof(*h); ) {
367 int len = h->nlmsg_len; 367 int len = h->nlmsg_len;
368 int l = len - sizeof(*h); 368 int l = len - sizeof(*h);
369 369
@@ -376,7 +376,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
376 exit(1); 376 exit(1);
377 } 377 }
378 378
379 if (nladdr.nl_pid != peer || 379 if ((pid_t)(nladdr.nl_pid) != peer ||
380 h->nlmsg_pid != rtnl->local.nl_pid || 380 h->nlmsg_pid != rtnl->local.nl_pid ||
381 h->nlmsg_seq != seq) { 381 h->nlmsg_seq != seq) {
382 /* Don't forget to skip that message. */ 382 /* Don't forget to skip that message. */
@@ -387,7 +387,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
387 387
388 if (h->nlmsg_type == NLMSG_ERROR) { 388 if (h->nlmsg_type == NLMSG_ERROR) {
389 struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); 389 struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
390 if (l < sizeof(struct nlmsgerr)) { 390 if (l < (int)sizeof(struct nlmsgerr)) {
391 fprintf(stderr, "ERROR truncated\n"); 391 fprintf(stderr, "ERROR truncated\n");
392 } else { 392 } else {
393 if (!err->error) { 393 if (!err->error) {
@@ -465,7 +465,7 @@ int rtnl_listen(struct rtnl_handle *rtnl,
465 fprintf(stderr, "Sender address length == %d\n", msg.msg_namelen); 465 fprintf(stderr, "Sender address length == %d\n", msg.msg_namelen);
466 exit(1); 466 exit(1);
467 } 467 }
468 for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { 468 for (h = (struct nlmsghdr*)buf; status >= (int)sizeof(*h); ) {
469 int err; 469 int err;
470 int len = h->nlmsg_len; 470 int len = h->nlmsg_len;
471 int l = len - sizeof(*h); 471 int l = len - sizeof(*h);
@@ -528,7 +528,7 @@ int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler,
528 len = h->nlmsg_len; 528 len = h->nlmsg_len;
529 l = len - sizeof(*h); 529 l = len - sizeof(*h);
530 530
531 if (l<0 || len>sizeof(buf)) { 531 if (l < 0 || len > (int)sizeof(buf)) {
532 fprintf(stderr, "!!!malformed message: len=%d @%lu\n", 532 fprintf(stderr, "!!!malformed message: len=%d @%lu\n",
533 len, ftell(rtnl)); 533 len, ftell(rtnl));
534 return -1; 534 return -1;
@@ -619,7 +619,7 @@ printf("\tdata length: %d\n", alen);
619 int len = RTA_LENGTH(alen); 619 int len = RTA_LENGTH(alen);
620 struct rtattr *rta; 620 struct rtattr *rta;
621 621
622 if (NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len) > maxlen) { 622 if ((int)(NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len)) > maxlen) {
623 fprintf(stderr, "addattr_l ERROR: message exceeded bound of %d\n",maxlen); 623 fprintf(stderr, "addattr_l ERROR: message exceeded bound of %d\n",maxlen);
624 return -1; 624 return -1;
625 } 625 }
@@ -673,7 +673,7 @@ else
673 673
674int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len) 674int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len)
675{ 675{
676 if (NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len) > maxlen) { 676 if ((int)(NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len)) > maxlen) {
677 fprintf(stderr, "addraw_l ERROR: message exceeded bound of %d\n",maxlen); 677 fprintf(stderr, "addraw_l ERROR: message exceeded bound of %d\n",maxlen);
678 return -1; 678 return -1;
679 } 679 }
@@ -792,7 +792,7 @@ int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int l
792int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta, 792int __parse_rtattr_nested_compat(struct rtattr *tb[], int max, struct rtattr *rta,
793 int len) 793 int len)
794{ 794{
795 if (RTA_PAYLOAD(rta) < len) 795 if ((int)RTA_PAYLOAD(rta) < len)
796 return -1; 796 return -1;
797 if (RTA_PAYLOAD(rta) >= RTA_ALIGN(len) + sizeof(struct rtattr)) { 797 if (RTA_PAYLOAD(rta) >= RTA_ALIGN(len) + sizeof(struct rtattr)) {
798 rta = RTA_DATA(rta) + RTA_ALIGN(len); 798 rta = RTA_DATA(rta) + RTA_ALIGN(len);
diff --git a/src/lib/pid.c b/src/lib/pid.c
index a0261ead2..1a1797ce2 100644
--- a/src/lib/pid.c
+++ b/src/lib/pid.c
@@ -222,15 +222,18 @@ static void print_elem(unsigned index, int nowrap) {
222// recursivity!!! 222// recursivity!!!
223void pid_print_tree(unsigned index, unsigned parent, int nowrap) { 223void pid_print_tree(unsigned index, unsigned parent, int nowrap) {
224 print_elem(index, nowrap); 224 print_elem(index, nowrap);
225
226 // Remove unused parameter warning
227 (void)parent;
225 228
226 int i; 229 unsigned i;
227 for (i = index + 1; i < max_pids; i++) { 230 for (i = index + 1; i < (unsigned)max_pids; i++) {
228 if (pids[i].parent == index) 231 if (pids[i].parent == (pid_t)index)
229 pid_print_tree(i, index, nowrap); 232 pid_print_tree(i, index, nowrap);
230 } 233 }
231 234
232 for (i = 0; i < index; i++) { 235 for (i = 0; i < index; i++) {
233 if (pids[i].parent == index) 236 if (pids[i].parent == (pid_t)index)
234 pid_print_tree(i, index, nowrap); 237 pid_print_tree(i, index, nowrap);
235 } 238 }
236} 239}
@@ -245,6 +248,9 @@ void pid_store_cpu(unsigned index, unsigned parent, unsigned *utime, unsigned *s
245 *utime = 0; 248 *utime = 0;
246 *stime = 0; 249 *stime = 0;
247 } 250 }
251
252 // Remove unused parameter warning
253 (void)parent;
248 254
249 unsigned utmp = 0; 255 unsigned utmp = 0;
250 unsigned stmp = 0; 256 unsigned stmp = 0;
@@ -252,9 +258,9 @@ void pid_store_cpu(unsigned index, unsigned parent, unsigned *utime, unsigned *s
252 *utime += utmp; 258 *utime += utmp;
253 *stime += stmp; 259 *stime += stmp;
254 260
255 int i; 261 unsigned i;
256 for (i = index + 1; i < max_pids; i++) { 262 for (i = index + 1; i < (unsigned)max_pids; i++) {
257 if (pids[i].parent == index) 263 if (pids[i].parent == (pid_t)index)
258 pid_store_cpu(i, index, utime, stime); 264 pid_store_cpu(i, index, utime, stime);
259 } 265 }
260 266