Rsyslog: logctl.c (mongodb): -Werror=declaration-after-statement, -Werror=switch-default, -Werror=strict-prototypes, -Werror=old-style-definition, -Werror=declaration-after-statement, -Werror=maybe-uninitialized errors

Created on 23 Nov 2017  Â·  10Comments  Â·  Source: rsyslog/rsyslog

Found via GCC 7.2.0 in current git master (326af71fbdb3a7347d8147b49b8391f40005b4e0):

logctl.c: In function ‘formater’:
logctl.c:137:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  char str[N];
  ^~~~
logctl.c: In function ‘getoptions’:
logctl.c:194:5: error: switch missing default case [-Werror=switch-default]
     switch (iarg)
     ^~~~~~
logctl.c: At top level:
logctl.c:243:27: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
 static struct select_doc* create_select()
                           ^~~~~~~~~~~~~
logctl.c: In function ‘create_select’:
logctl.c:243:27: error: old-style function definition [-Werror=old-style-definition]
logctl.c: At top level:
logctl.c:332:27: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
 static struct db_connect* create_conn()
                           ^~~~~~~~~~~
logctl.c: In function ‘create_conn’:
logctl.c:332:27: error: old-style function definition [-Werror=old-style-definition]
logctl.c: In function ‘launch_query’:
logctl.c:367:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  const bson_t *opts = BCON_NEW (
  ^~~~~
logctl.c: In function ‘main’:
logctl.c:306:4: error: ‘opt.e_dateu’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    strptime (opt->e_dateu, "%d/%m/%Y-%H:%M:%S", &tm);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
logctl.c:417:18: note: ‘opt.e_dateu’ was declared here
  struct queryopt opt;
                  ^~~
logctl.c:317:3: error: ‘opt.e_sys’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   bson_append_utf8 (query_what, "sys", 3, opt->e_sys, -1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
logctl.c:417:18: note: ‘opt.e_sys’ was declared here
  struct queryopt opt;
                  ^~~
logctl.c:283:3: error: ‘opt.e_msg’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   bson_append_utf8 (msg_what, "$regex", 6,  opt->e_msg, -1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
logctl.c:417:18: note: ‘opt.e_msg’ was declared here
  struct queryopt opt;
                  ^~~
logctl.c:275:3: error: ‘opt.e_level’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   bson_append_utf8 (query_what, "level", 5, opt->e_level, -1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
logctl.c:417:18: note: ‘opt.e_level’ was declared here
  struct queryopt opt;
                  ^~~
logctl.c:296:4: error: ‘opt.e_date’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    strptime (opt->e_date, "%d/%m/%Y-%H:%M:%S", &tm);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
logctl.c:417:18: note: ‘opt.e_date’ was declared here
  struct queryopt opt;
                  ^~~

bug

All 10 comments

@HugoSoszynski I wonder if you would be willing to help out with that one? If you have no time, no problem at all, but I thought this would be a nice follow-up you may be interested in.

@rgerhards I will take it. I think it will be done during the weekend.

Excellent, much appreciated! I guess you do not necessarily need to have gcc-7 on the system, but it would help. If you do not have it, let me know I may be able to help you find a suitable solution. Maybe I manage to get some version integrated into Travis today, but that's not yet for sure ;-)

The gcc version of my system is 7.2.1. As long as there are just compilation errors, I think it will do the job. I will try to setup some dockers to test with other versions.

I think 7.2.1 is perfect and sufficient. I suggest to use CI for all others. You can also sign up for free with Travis, than you can run many tests even before doing a PR.

In my quest to make the logctl.c code fully ISO C90 compliant, I found that libmongoc and libbson are not. I am able to compile with the -ansi flag without any warning but due to the precedent libs, I would strongly suggest to not use the -Wpedantic flag.

Currently doing further compilation testing.

@HugoSoszynski sorry for the long silence. I had to wrangle with some very nasty bugs. It sound so like you more or less have a solution to this issue. Would you be willing to post a PR?

@rgerhards Don't worry, I have had a lot of work on my side too :). The corrections are already done in my fork. The last thing left to do is to sync my repo with the master.

I should post a PR by Tuesday.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings