Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martin-barta-sie
Copy link
Contributor

No description provided.

Copy link
Member

@DDvO DDvO left a 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)
Copy link
Member

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.

Comment on lines +110 to +111
assert(beg <= end);
size_t len = (size_t)(end - beg);
Copy link
Member

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 */.

Comment on lines +87 to +88
assert(pos_p >= src_p);
line_len = (size_t)(pos_p - src_p);
Copy link
Member

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.
Copy link
Member

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.

Comment on lines +124 to +125
assert(end is_eq 0 or end >= uri);
size_t len = end not_eq 0 ? (size_t)(end - uri) : strlen(uri);
Copy link
Member

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)++);
Copy link
Member

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);
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants