[systemd-devel] [PATCH] udev: Allow acpi_index and index to be "0"

Mantas Mikulėnas grawity at gmail.com
Sat Sep 29 10:15:37 UTC 2018


On Fri, Sep 28, 2018, 23:49 Joe Hershberger <joe.hershberger at ni.com> wrote:

> 0 can be a valid index returned by the BIOS, so allow that literal while
> still checking for 0 as a failed conversion by strtoul(). Also, unsigned
> long cannot be negative, so don't misleadingly check for less than 0.
>
> Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
> ---
>  src/udev/udev-builtin-net_id.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/udev/udev-builtin-net_id.c
> b/src/udev/udev-builtin-net_id.c
> index 5341d3788..338a2d4c4 100644
> --- a/src/udev/udev-builtin-net_id.c
> +++ b/src/udev/udev-builtin-net_id.c
> @@ -232,7 +232,7 @@ static int dev_pci_onboard(struct udev_device *dev,
> struct netnames *names) {
>                  return -ENOENT;
>
>          idx = strtoul(attr, NULL, 0);
> -        if (idx <= 0)
> +        if (idx == 0 && strcmp("0", attr))
>

If error checking is needed, wouldn't it be better to use the error
checking that strtoul itself provides?

("If endptr is not NULL, strtoul() stores the address of the first invalid
character in *endptr.")

>
> --

Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180929/d71428df/attachment.html>


More information about the systemd-devel mailing list