Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolved warning, corrected includes #301

Closed
wants to merge 19 commits into from

Conversation

Projects
None yet
2 participants
@NeuroCopter
Copy link
Contributor

commented May 24, 2013

resolved issues that showed up when enabling:
-Wreorder (no -Wno-reorder)
-Woverloaded-virtual
-Wsign-promo
-Wtype-limits
-Wsign-conversion
-Wconversion

corrected includes in AP_HAL/ e.g.

include "Print.h" --> #include "utility/Print.h"

NeuroCopter and others added some commits May 15, 2013

corrected includes:
replaces #inlcude "$HEADER" with #inlcude "utility/$HEADER"

adding -I for EVERY DIRECTORY isn't desirable

http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html
tobias
added casts to remove warnings:
warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]

(dump_log > 0 => signed to unsigned cast is safe)
corrected format string
ArduCopter/AP_State.pde:139:42: warning:
format '%u' expects argument of type 'unsigned int', but argument 3 has
type 'uint32_t {aka long unsigned int}' [-Wformat]

these warnings exist for a reason ...
A_AHRS_DCM: virtual function from base class AP_AHRS was hidden.
ArduCopter/libraries/AP_AHRS/AP_AHRS.h:143:18:
‘virtual bool AP_AHRS::use_compass() const’

was hidden In file

ArduCopter/libraries/AP_AHRS/AP_AHRS_DCM.h:63:21:
by ‘bool AP_AHRS_DCM::use_compass()’

Also fixed const-ness of have_gps
resolved -Woverloaded-virtual warning:
virtual size_t AP_HAL::Print::write(const uint8_t *buffer, size_t size);

was hidden in all derived classes by their
virtual size_t write(uint8_t) = 0; implementations.

To solve this, a non-virtual write(const uint8_t *, size_t) that calls a
virtual write_implementation was added.

This isn't necessary atm, because the derived classes don't call
write(const uint8_t *, size_t), BUT this decreases the apm2-quad Program
size by 40 bytes :D and removes warnings.
validity of array index was checked AFTER accessing the element.
(correction decreased Program size by 12 bytes)
* removed useless comparison: if (int8_t t >= 255) ...
* revealed by -Wtype-limits
* saved 6 bytes
Merge remote-tracking branch 'diydrones/master'
Conflicts:
	ArduCopter/AP_State.pde
removed useless comparison
uint_ >= 0
(-Wtype-limits)
extended .gitignore:
.directory (Dolphin's .DS_Store)
/.settings/ (eclipse)
* added comment
* replaced "~0" with the appropriate macro
* resolved -Wconversion
* saved some space by modifying AP_Param::add_vector_suffix (writing
behind buffer could happen, if buffer_size is almost uint16_max but this
can surely be ignored)

further reading:
http://stackoverflow.com/questions/809227/is-it-safe-to-use-1-to-set-all-bits-to-true
@tridge

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2013

Thanks Tobias!
I've applied most of these with some minor changes.
One I didn't applied was the FILTER_SIZE check for <= 129, as if we started adding those we'd have hundreds of places to put them, and it would make the code harder to follow.
For the rest my main changes were to make the commit messages follow our conventions.
Thanks for your work on this!
Cheers, Tridge

@tridge tridge closed this Jul 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.