Sorry for the long wait on feedback.  This patchs looks okay, but I do
have a few nits to pick...

On Mon, Jul 24, 2017 at 05:07:46PM +0300, Feras Daoud wrote:
> diff --git a/raw.c b/raw.c
> index 73e45b45bd25..559c93315154 100644
> --- a/raw.c
> +++ b/raw.c
> @@ -220,7 +220,7 @@ static int raw_open(struct transport *t, const char *name,
>       mac_to_addr(&raw->ptp_addr, ptp_dst_mac);
>       mac_to_addr(&raw->p2p_addr, p2p_dst_mac);
>  
> -     if (sk_interface_macaddr(name, &raw->src_addr))
> +     if (sk_interface_hwaddr(name, &raw->src_addr))

I don't see a real need to rename this function, but if you really
want to, please do it in a separate patch.

> diff --git a/sk.c b/sk.c
> index 63ec20688efc..62bf759079d4 100644
> --- a/sk.c
> +++ b/sk.c
> @@ -159,10 +159,40 @@ failed:
>       return -1;
>  }
>  
> -int sk_interface_macaddr(const char *name, struct address *mac)
> +static int sk_interface_guidaddr(const char *name, unsigned char *guid)
> +{
> +     char file_name[64], buf[64], addr[8];
> +     FILE *f;
> +
> +     snprintf(file_name, sizeof buf, "//sys//class//net//%s//address", name);

No need to have double // slashes.

> +     f = fopen(file_name, "r");
> +     if (!f) {
> +             printf("failed to open %s\n", buf);
> +             return -1;
> +     }
> +
> +     /* Set the file position to the beginning of the GUID */
> +     fseek(f, GUID_OFFSET, SEEK_SET);
> +
> +     if (fgets(buf, sizeof buf, f) > 0) {
> +             sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
> +                          &addr[0], &addr[1], &addr[2], &addr[3],
> +                          &addr[4], &addr[5], &addr[6], &addr[7]);

You should check the return value of sscanf().

Thanks,
Richard

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to