Fix some compilation warnings.#33
Conversation
DDvO
left a comment
There was a problem hiding this comment.
Thanks for these fixes;
just a couple of improvements suggested.
| len = SECTION_NAME_MAX; | ||
| } | ||
| strncpy(opt_item, beg, len); | ||
| if(len > 0) |
There was a problem hiding this comment.
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.
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.
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.
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.
Also here, I suggest not using assert() but optionally just adding a comment.
| for(i = 0; i < num_out; i++) | ||
| { | ||
| char c = *((*in_p)++); | ||
| int c = *((*in_p)++); |
There was a problem hiding this comment.
Why this change?
Note that *in_p is of type const char*
| { | ||
| (*decoded_len)--; | ||
| } | ||
| assert(*decoded_len >= 0); |
There was a problem hiding this comment.
Also here, I suggest replacing the assertion by a comment.
No description provided.