s-a / iso-8583

:credit_card: A native Node module to process ISO 8583 Financial transaction card originated messages
Other
76 stars 30 forks source link

Fixed multiple gcc v7.2.0 warnings #8

Closed timgabets closed 6 years ago

timgabets commented 6 years ago

There is a number of warnings shown while compiling lib/ :

../lib/dl_str.c:48:34: warning: pointer targets in passing argument 1 of ‘getenv’ differ in signedness [-Wpointer-sign] return DL_STR_SafeStr(getenv(iEnvStr));

../lib/dl_str.c:209:44: warning: passing argument 2 of ‘DL_MEM_malloc’ from incompatible pointer type [-Wincompatible-pointer-types] else if ( err = DL_MEM_malloc(iMaxChars+1,oStr) )

../lib/dl_str.c:209:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses] else if ( err = DL_MEM_malloc(iMaxChars+1,oStr) )

../lib/dl_time.c:338:22: warning: zero-length gnu_printf format string [-Wformat-zero-length] sprintf(ioFormatStr,"");

s-a commented 6 years ago

Hi . Thanks for your PR. I do not know C but i compared your code with master Branch where your PR produces one more waning

Your code

..\lib\dl_iso8583_fields.c(453): warning C4018: "<": Konflikt zwischen "signed" und "unsigned" [c:\git\iso-8583\build\I
SO8583.vcxproj]
..\lib\dl_str.c(132): warning C4013: "toupper" undefiniert; Annahme: extern mit Rückgabetyp int [c:\git\iso-8583\build\
ISO8583.vcxproj]
..\lib\dl_str.c(546): warning C4244: "Funktion": Konvertierung von "__int64" in "DL_UINT32", möglicher Datenverlust [c:
\git\iso-8583\build\ISO8583.vcxproj]

Master branch

..\lib\dl_str.c(132): warning C4013: "toupper" undefiniert; Annahme: extern mit Rückgabetyp int [c:\git\iso-8583\build\ISO8583.vcxproj]
..\lib\dl_str.c(546): warning C4244: "Funktion": Konvertierung von "__int64" in "DL_UINT32", möglicher Datenverlust [c:\git\iso-8583\build\ISO8583.vcxproj
]

I am on Windows 10. Where do you compile the code? Anyway your changes seems to make sense for a C noop. 😄

timgabets commented 6 years ago

Hi, first of all, thank you for the library - it's really cool, and I'm gonna use it in a number of my applications ;)

I'm using GCC v6.2.0 (released Aug 2016) on Linux, and while building the lib with npm install, there's tons of compiler warnings.

Regarding this newly appeared warning with my branch on your machine (it's MS Visual Studio C I believe, by the way, which version do you use?).:

..\lib\dl_iso8583_fields.c(453): warning C4018: "<": Konflikt zwischen "signed" und "unsigned" [c:\git\iso-8583\build\I
SO8583.vcxproj]

is caused by this piece of code:

442 DL_ERR _pack_iso_BITMAP ( DL_UINT16                    iField,
443                     const DL_ISO8583_MSG        *iMsg,
444                     const DL_ISO8583_FIELD_DEF  *iFieldDefPtr,
445                     DL_UINT8                   **ioPtr ) 
446 {
447    DL_ERR     err         = kDL_ERR_NONE;
448    DL_UINT8  *tmpPtr      = *ioPtr;
449    DL_UINT16  curFieldIdx = iField;
450    unsigned i;
451 
452    /* for each possible bitmap segment */
453    for ( i=0 ; i<((kDL_ISO8583_MAX_FIELD_IDX-iField+1)+63)/64 ; i++ ) 

iField is DL_UINT16 (which is unsigned), therefore (kDL_ISO8583_MAX_FIELD_IDX-iField+1) should be unsigned as well, and I wonder that VS compiler thinks some other way and theats it as warning.

s-a commented 6 years ago

I am Using VS 2017. I will merge the PR. Seems you brought pretty much better code quality in here :)

s-a commented 6 years ago

Did you receive the collaborator invitation? https://github.com/s-a/iso-8583/invitations.