volkszaehler / libsml

Implementation in C of the Smart Message Language (SML) protocol
GNU General Public License v3.0
88 stars 49 forks source link

fix: compiler warning about char -> unsigned char #118

Closed rotorman closed 1 year ago

rotorman commented 1 year ago

Fixes a compiler warning when building without libuuid.

Without libuuid (SML_NO_UUID_LIB defined), the code takes the path via line 107: https://github.com/volkszaehler/libsml/blob/7e7c5d46f82a8c8ce50c9be150da0c35bc0168cb/sml/src/sml_octet_string.c#L103-L107

Line 122 calls sml_octet_string_init() with uuid char array variable as the first parameter: https://github.com/volkszaehler/libsml/blob/7e7c5d46f82a8c8ce50c9be150da0c35bc0168cb/sml/src/sml_octet_string.c#L122

sml_octet_string_init() expects unsigned char instead of char as the first argument: https://github.com/volkszaehler/libsml/blob/7e7c5d46f82a8c8ce50c9be150da0c35bc0168cb/sml/src/sml_octet_string.c#L35

devZer0 commented 1 year ago

hi ! thank you for submitting.

but can you point out what compiler warning does this fix ? which compiler/version/platform ?

i don't get a warning on recent debian

rotorman commented 1 year ago

I was testing with Teensy 4.0 (Freescale MIMXRT1062, ARM Cortex M7) under Arduino IDE v2.04. Teensyduino uses Arm GNU toolchain in v11.3.1

devZer0 commented 1 year ago

ok. what's the compilers complaint ?

rotorman commented 1 year ago
c:\Users\rotorman\Documents\Arduino\libraries\libSML\src\sml_octet_string.c: In function 'sml_octet_string_generate_uuid':
c:\Users\rotorman\Documents\Arduino\libraries\libSML\src\sml_octet_string.c:122:38: warning: pointer targets in passing argument 1 of 'sml_octet_string_init' differ in signedness [-Wpointer-sign]
  122 |         return sml_octet_string_init(uuid, 16);
      |                                      ^~~~
      |                                      |
      |                                      char *
c:\Users\rotorman\Documents\Arduino\libraries\libSML\src\sml_octet_string.c:35:52: note: expected 'unsigned char *' but argument is of type 'char *'
   35 | octet_string *sml_octet_string_init(unsigned char *str, int length) {
      |                                     ~~~~~~~~~~~~~~~^~~
r00t- commented 1 year ago

sorry for the delayed response.

your commit/MR is missing some details that make it hard to get the context.

the issue occurs:

can you maybe update your commit message to provide a little more detail? i'd merge this then.

rotorman commented 1 year ago

Done, thank you for the hints!

r00t- commented 1 year ago

sorry, i meant to update the git commit message (as this will go int the project's git history), not the pull request description (but that also looks much nicer now!)

r00t- commented 1 year ago

i missed that gitlab lets me edit the message with "squash and merge" => merged. thanks for your contribution!