acado/acado — pull request #32 by roryyorke (2013-07-13 12:43:35+00:00)
Title: Minor warnings

This is the first of three branches aimed at removing warnings when compiling ACADO with gcc.

When all three branches are combined, only two warnings remain when compiling on my mostly stock Ubuntu 13.04 system:

/home/rory/git/acado/src/user_interaction/plot_window.cpp:734:15: warning: variable ‘logFrequency’ set but not used [-Wunused-but-set-variable]

/home/rory/git/acado/examples/code_generation/nmpc/getting_started_export/integrator.c:246:1: warning: ‘error’ is used uninitialized in this function [-Wuninitialized]

Both of these seem to be bugs. The first appears to be simple to fix. The second is in what looks like generated code, so presumably fixing integrator.c won't help.

I have tested the changes by running all of the examples (that is, every binary under examples/) with current ACADO master, and then running everything with all of the branches applied. The results are similar; this I deduced by comparing the text files created by the examples, and recording the standard output and standard error output. In both cases the same examples fail in the same ways, including one segfault that somehow manages to output to console (i.e., bypassing redirection of stdout and stderr).

This branch (minor-warnings) includes the simpler changes required to silence various gcc warnings. A number of these are unused variables, or unused-but-set variables.

Some things probably requiring attention in review:
- statements involving unused-but-set variables may be relying on side-effects, though as far as I can see this is not the case.
- gcvt, accord the glibc man page and implementation, returns its third argument, but is marked warn_unused_result in glibc. There's one usage of this function "in the wild" that actually checks the return value: http://sources.debian.net/src/perl/5.14.2-21/uts/sprintf_wrap.c?hl=144#L144 , but I don't know if this is correct. It might be simpler to use snprintf with %g.