You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (! (strncmp(argv[i], "option", __maxlen(7, strlen(argv[i])) == 0) )
In some places even strncasecmp() is used.
All those approaches look awfully redundant, cumbersome and unprofessional. They also lead to problems described in aforementioned ticket.
This issue is to capture the effort to clean them all up and switch to using simple strcmp() wherever normal C strings coming from command line arguments or console input are compared.
There are also places where strncmp() is used to compare IPMI strings without the null-byte terminator and with a type/length byte prefix instead. Those must be left as is (or maybe converted to using some new helper function like ipmi_strcmp()).
The text was updated successfully, but these errors were encountered:
Unify the comparison idioms use.
Always use `if(!strcmp())` for "if string equals"
and `if(strcmp())` for "if string is not equal".
Never use `== 0` and `!= 0` with `strcmp()`.
Minor reformatting of the code immediately surrounding the
refactored lines.
Resolvesipmitool#104
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
cleanupThe issue is to clean up or refactor the existing code
This is associated with SourceForge ticket 24.
In many places command line arguments are matched using some weird constructions like
or
or
or even
In some places even
strncasecmp()
is used.All those approaches look awfully redundant, cumbersome and unprofessional. They also lead to problems described in aforementioned ticket.
This issue is to capture the effort to clean them all up and switch to using simple
strcmp()
wherever normal C strings coming from command line arguments or console input are compared.There are also places where
strncmp()
is used to compare IPMI strings without the null-byte terminator and with a type/length byte prefix instead. Those must be left as is (or maybe converted to using some new helper function likeipmi_strcmp()
).The text was updated successfully, but these errors were encountered: