Skip to content

Patch to Sd2Card.cpp to elimimate compiler warnings #15

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

Closed
wants to merge 9 commits into from
Closed

Patch to Sd2Card.cpp to elimimate compiler warnings #15

wants to merge 9 commits into from

Conversation

jcwren
Copy link

@jcwren jcwren commented Dec 21, 2010

The SPIF while() loop code generates a "warning: suggest a space before ';' or explicit braces around empty body in 'while' statement" when compiling with -W -Wall. This patch breaks the semi-colons on to the next line to eliminate the warning and made the code clearer.

….lst file generation, avr-size output

This patch adds 4 preferences.txt options to support enabling -W and -Wall
flags when compiling, producing a .map file as part of the linking stage,
producing a diassembly list file after linking, and a more verbose size output.

Adding 'compiler.show_all_warnings=true' to preferences.txt adds the -W and
-Wall flags passed to the compiler, and removes the -w flag.  This produces
informative verbose warnings about less than ideally constructed code, such as
signed vs unsigned comparisons, unused variables, and a great deal of other
useful information.

Adding 'compiler.map_file=true' causes the linker to produce a detailed map
file listing of the code.  This file is written to the directory the sketch is
located in.

Adding 'compiler.lst_file=true' causes avr-objdump to be run on the produced
.elf file.  The listing file contains a disassembled listing of the code
intermixed with the source code.  The -d (Display assembler contents of
executable sections) and -S (Intermix source code with disassembly) options are
passed to avr-objdump.  The resulting .lst file is written to the directory the
sketch is located in.

Adding 'compiler.detailed_size' causes avr-size to be run on the produced .elf
file.   This displays a more detailed report the combined sizes of the program
space (.text + .data + .bootloader), and the combined sizes of data space
(.data + .bss + .noinit)

Unfortunately, avr-objdump does not support a command line option to specify
where to write the output of the program to.  Instead, EVERYTHING goes to
stdout.  Normally anything written to stdout by an exec'ed program is written
to the status window of the Arduino IDE.  To get the the stdout of avr-objdump
captured to be written to an output file required a tad bit hackishness in the
execAsynchronously function.  See source for details.
Print currently uses a signed vs unsigned comparison in Print::print(const String &s) while iterating through individual characters.
This causes compiler warnings when using -W -Wall.
The static keyword is improperly placed in the declaration of the intFunc
variable.
Compiling with -W -Wall flags revealed that the 'base' variable in the
parameter list for String::String( const long value, const int base )
was not being passed to the ultoa() function.  Instead, the parameter
to ultoa() was hard-coded to 10.
The length() function has a useless 'const' keyword in the declation, causing
the compiler to throw a "type qualifiers ignored on function return type"
warning when compiled with -W -Wall.
This patch fixes the "initialization makes integer from pointer without a cast"
warning generated by the compiler when using the -W -Wall flags.  The data type
in the array is a uint16_t, but DDRA (for example) is a pointer.  A cast is
required to make GCC happy.
The SPI pins are declared as 'const static' instead of 'static const', causing
the compiler to throw a warning with the -W -Wall flags are used.
When compiling with the -W -Wall flags, a warning is emitted indicating that
<avr/delay.h> has been moved to <util/delay.h>.  This patch fixes the #include
to point to the new location.
All the while() loops that check for the SPI transfer to be complete have the
semi-colon immediately after the closing parenthesis.  This both causes a
compiler warning of "warning: suggest a space before ';' or explicit braces
around empty body in 'while' statement", and is considered a less-than-ideal
programming practice.  This patch breaks the semi-colon on to the next line,
both eliminating the compiler error and making the code more readable.

In all probability the test should be moved into a macro or a inlineable
sub-routine.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant