Skip to content
New issue

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

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

Already on GitHub? # to your account

Compiler warning on RTEMS #30

Closed
jphickey opened this issue Dec 9, 2019 · 0 comments · Fixed by #34
Closed

Compiler warning on RTEMS #30

jphickey opened this issue Dec 9, 2019 · 0 comments · Fixed by #34
Labels
bug Something isn't working build-system
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented Dec 9, 2019

Describe the bug
When compiling on RTEMS this application now has multiple warnings:

/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c: In function 'SAMPLE_AppInit':
/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c:166:30: error: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'int32' [-Werror=format=]
                              status);
                              ^
/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c:187:30: error: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'int32' [-Werror=format=]
                              status);
                              ^
/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c:199:30: error: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'int32' [-Werror=format=]
                              status);
                              ^
/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c:211:30: error: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'int32' [-Werror=format=]
                              status);
                              ^
/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c:226:9: error: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'int32' [-Werror=format=]
         CFE_ES_WriteToSysLog("Sample App: Error Registering \
         ^
/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c: In function 'SAMPLE_GetCrc':
/home/joe/code/cfecfs/github/apps/sample_app/fsw/src/sample_app.c:535:9: error: format '%X' expects argument of type 'unsigned int', but argument 2 has type 'uint32' [-Werror=format=]
         CFE_ES_WriteToSysLog("Sample App: CRC: 0x%08X\n\n", Crc);
         ^

To Reproduce
Build on RTEMS per the readme/howto and with -Wall -Werror switches

Expected behavior
Should build clean

System observed on:
Ubuntu 18.04 (build host) when cross compiling for RTEMS 4.11

Additional context
Appears the problem calls were introduced in #1

As a rule of thumb, whenever "printf" style conversions are used in conjunction with the fixed-width types (int32, uint32, etc) these need an explicit cast because the actual type definitions vary by platform.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

jphickey added a commit that referenced this issue Dec 10, 2019
When using printf-style format conversions one must generally
cast the argument to the intended type, as it does not happen
implicitly with variable-argument functions.

In particular the existing code worked on the default (native) build
but generated warnings when building on RTEMS for a 32-bit x86 target.
skliper pushed a commit that referenced this issue Dec 30, 2019
When using printf-style format conversions one must generally
cast the argument to the intended type, as it does not happen
implicitly with variable-argument functions.

In particular the existing code worked on the default (native) build
but generated warnings when building on RTEMS for a 32-bit x86 target.
@skliper skliper added this to the 1.2.0 milestone Dec 30, 2019
@skliper skliper added the enhancement New feature or request label Dec 30, 2019
skliper added a commit that referenced this issue Dec 30, 2019
Fix #23, #25, #28, #30
Reviewed and approved at 2019-12-18 CCB
@astrogeco astrogeco added bug Something isn't working build-system and removed enhancement New feature or request labels Oct 1, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working build-system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants