-
Notifications
You must be signed in to change notification settings - Fork 4
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 some compilation warnings. #33
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for these fixes;
just a couple of improvements suggested.
if(len > SECTION_NAME_MAX) | ||
{ | ||
len = SECTION_NAME_MAX; | ||
} | ||
strncpy(opt_item, beg, len); | ||
if(len > 0) |
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.
This guard is not needed since it is equivalent to len != 0
, and if len == 0
, strncpy()
will do nothing anyway.
assert(beg <= end); | ||
size_t len = (size_t)(end - beg); |
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.
Well, from the five lines before it should already be clear that beg <= end.
So I do not see the need for the assertion and thus also not for the include <assert.h>
.
Yet maybe append to the next (assignment) line a comment such as: /* note that beg <= end */
.
assert(pos_p >= src_p); | ||
line_len = (size_t)(pos_p - src_p); |
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.
Also here, I suggest replacing the new assertion by, e.g., /* note that pos_p >= src_p */
at the end of the following line
and removing the #include <assert.h>
.
@@ -51,9 +52,9 @@ static int file_modified; | |||
* Keeps any end-of-line comment. | |||
* Returns the length of the resulting line, or 0 in case of error. |
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.
Please correct the comment: or -1 in case of error.
assert(end is_eq 0 or end >= uri); | ||
size_t len = end not_eq 0 ? (size_t)(end - uri) : strlen(uri); |
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.
Also here, I suggest not using assert()
but optionally just adding a comment.
@@ -525,18 +526,18 @@ bool UTIL_hex_to_bytes(const char** in_p, unsigned char* out, unsigned int num_o | |||
num_out *= HEX_CHARS_PER_BYTE; | |||
for(i = 0; i < num_out; i++) | |||
{ | |||
char c = *((*in_p)++); | |||
int c = *((*in_p)++); |
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.
Why this change?
Note that *in_p
is of type const char*
@@ -612,6 +611,7 @@ unsigned char* UTIL_base64_decode(const char* b64_data, int b64_len, int* decode | |||
{ | |||
(*decoded_len)--; | |||
} | |||
assert(*decoded_len >= 0); |
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.
Also here, I suggest replacing the assertion by a comment.
No description provided.