Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/if-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -2193,9 +2193,22 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
return -1;
#else
fp = strwhite(arg);
if (fp)
*fp++ = '\0';
u = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e);
bp = NULL;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bp may not be the best variable for this purpose, wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code readability, bp seems to be used specifically to parsing bit flags.
You may want to add another pointer for this class of data.

fp for field pointer
bp for bit flag pointer
np for network pointer (addresses and such)
dp for byte data pointer?

/* Command line options are parsed globally and then replayed
* per-interface using the same argv, so do not split optarg
* in-place. Later passes still need the data after the EN. */
if (fp) {
dl = (size_t)(fp - arg);
bp = malloc(dl + 1);
if (!bp) {
logerr(__func__);
return -1;
}
memcpy(bp, arg, dl);
bp[dl] = '\0';
}
u = (uint32_t)strtou(bp ? bp : arg, NULL, 0, 0, UINT32_MAX, &e);
free(bp);
if (e) {
logerrx("invalid code: %s", arg);
return -1;
Expand Down