-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fix compiler warnings #75
Fix compiler warnings #75
Conversation
Changes fix following errors: - encode/signed-interest.c:298:24: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘unsigned int’} and ‘int’ - encode/signed-interest.c:347:24: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘unsigned int’} and ‘int’ - encode/signed-interest.c:395:24: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘unsigned int’} and ‘int’ - encode/wrapper-api.c:256:17: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ - encode/wrapper-api.c:670:17: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ - forwarder/name-tree.c:88:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘unsigned int’} - forwarder/name-tree.c:117:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘unsigned int’} - forwarder/name-tree.c:168:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘unsigned int’} NOTE: some changes are just removal of white spaces (automatically applied by my IDE).
Changes fix following error: - encode/wrapper-api.c:405:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
Changes fix following warnings: - encode/encrypted-payload.c:117:23: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘uint32_t’ {aka ‘unsigned int’} - encode/encrypted-payload.c:117:23: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’}
Changes fix following errors: - security/ndn-lite-hmac.c:146:18: warning: comparison of unsigned expression < 0 is always false (3 errors on the same line)
Changes fix following errors: - encode/key-storage.c:126:1: error: old-style function definition - encode/key-storage.c:156:1: error: old-style function definition
Changes fixes following warnings: - forwarder/forwarder.c:314:1: error: control reaches end of non-void function
Changes fix following warnings: - forwarder/forwarder.c:311:37: error: passing argument 2 of ‘ndn_interest_tlv_encode’ discards ‘const’ qualifier from pointer target type NOTE: the cause of this warning is 'ndn_interest_tlv_encode' in which name components are updated to cater for a SHA256 digest.
Changes fix following warnings: - forwarder/name-tree.c:83:17: error: variable ‘last_node’ set but not used NOTE: this unused variable seems to be remainder of a 'copy/paste' action!
Changes fix following warnings: - encode/name-component.c:30:10: error: 'result' may be used uninitialized in this function [-Werror=maybe-uninitialized] - encode/../util/logger.h:25:3: error: 'keyid' may be used uninitialized in this function NOTE: this error occures only in older compilers that are not smart enough to understand that the uninitialized vale are filled out later.
4847b10
to
ae85f84
Compare
I still get a number of |
It’s necessary to have continuous integration that turns on |
In previous structure, NDN lite tests were in their own repository with NDN lite sources as a submodule in base directory. Here, the relationship is inverse, i.e., the tests are integrated directly in NDN lite repository. In this commit a really cheap trick (symlink to parent instead of submodule) is used to have the tests running without changing the source code. This might need some reconsideration in the future!
I tested f0998b4 on Ubuntu 16.04 using GCC 5.4.0. I'm still seeing warnings (that do not belong in test files). For example:
The proper way to resolve |
The proper way to resolve -Wformat is to #include <inttypes.h> and then use PRIu64 etc.
For things like ndn_time_us_t, add a #define PRI_ndn_time_us_t PRIu64 right next to the typedef declaring that time, then use PRI_ndn_time_us_t macro when you need to print a value of that type.
Yes, that also came to my attention after I posted the comment. This is obviously due to my lack of experience in writing portable/cross platform code!Thanks for the hint! I'll take care of it tomorrow.
|
Changes here make format strings portable and cross platform compatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/tmp/ndn-lite/tests/ndn-lite/app-support/security-bootstrapping.c: In function ‘sec_boot_send_cert_interest’:
/tmp/ndn-lite/tests/ndn-lite/app-support/security-bootstrapping.c:286:46: error: passing argument 5 of ‘ndn_forwarder_express_interest’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
&m_sec_boot_state.device_info->ser
^
In file included from /tmp/ndn-lite/tests/ndn-lite/app-support/security-bootstrapping.h:16:0,
from /tmp/ndn-lite/tests/ndn-lite/app-support/security-bootstrapping.c:11:
/tmp/ndn-lite/tests/ndn-lite/app-support/../forwarder/forwarder.h:167:1: note: expected ‘void *’ but argument is of type ‘const uint8_t * const {aka const unsigned char * const}’
ndn_forwarder_express_interest(uint8_t* interest, size_t length,
^
@yoursunny this is exactly what I'm talking about 👆 |
I think you are a better developer than most others, and you deserve a spot on the core team or become the project manager. |
sure, can I merge it first your project can move on? |
I'd recommend not to merge the current code, since it leaves the codebase in an uncompilable state. |
you should've been a politician or at least be awarded with a medal or something for your convincing skills :)
Thanks for the offer, but let's wait until everything is resolved. @yoursunny somehow convinced me to do take care of the rest... |
Changes fix following errors: - ndn-lite/app-support/security-bootstrapping.c:286:46: error: passing argument 5 of ‘ndn_forwarder_express_interest’ discards ‘const’ qualifier from pointer target type NOTE: This specific error was caused by inconsistend programming in declaring a pointer as const in one place but assigning it to other pointers which are not const.
Changes fix following warnings: - adaptation/udp/udp-face.c:206:7: error: variable ‘ret’ set but not used NOTE: it seems that original authors abruptly stopped coding...
Changes fix follwoing warnings: - tests/adaptation/security/ndn-lite-rng-posix-crypto-impl.c:31:18: error: implicit declaration of function ‘read’; did you mean ‘creat’?
So the warnings are fixed and the tests all pass. During this process I also discovered some bugs which makes me really wonder why these were not flagged by the unit tests 🤔 Anyhow, it has been a while since I've used Travis CI on GitHub and according to [its docs] you should first enable it for GitHub before using it. If I understand it correctly, it doesn't pick up jobs automatically anymore as it used to do. Nonetheless I added a preliminary CI script, wondering if it's gonna work! |
For Travis CI, you need to enable it on your fork first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm there's no more warning on Ubuntu 16.04 with GCC.
Travis script is the only problem. @yan-foto needs to enable Travis on his fork to confirm the result.
739f305
to
383db5a
Compare
383db5a
to
3bb4bdc
Compare
OK folks, everything works as expected. I really didn't want to work on shabbat, but I guess I also couldn't leave this cake half-baked! The unit tests pass but I still think the code needs more rigorous testing. So maybe we first merge this on the |
@tianyuan129 needs to install Travis CI in this repository. |
Sure. Currently I'm not the admin for this repository. Let me ask for the permission first and then I'll install it. |
@Zhiyi-Zhang needs to install Travis CI in this repository. |
just installed Travis CI on |
As discussed in #74 here is a set of changes that fix compiler warnings. Some of the changes are trivial and non-critical while the others fix some hidden bugs such as missing return statements and possibly unsafe pointer arithmetic.
Each commit addresses a specific warning type and additional information (if applicable) is also included in commit message.