Looks good now, except for a couple of nits...
On Tue, Aug 08, 2017 at 10:50:35AM +0300, Feras Daoud wrote:
> +static int sk_interface_guidaddr(const char *name, unsigned char *guid)
> +{
> + char file_name[64], buf[64], addr[8];
> + FILE *f;
> + int rc;
> +
> + snprintf(file_name, sizeof buf, "/sys/class/net/%s/address", name);
> + f = fopen(file_name, "r");
> + if (!f) {
> + pr_err("failed to open %s: %m", buf);
> + return -1;
> + }
> +
> + /* Set the file position to the beginning of the GUID */
> + fseek(f, GUID_OFFSET, SEEK_SET);
Error checking, please.
> + if (fgets(buf, sizeof buf, f) > 0) {
This function returns a pointer, so the test shouldn't use '>'.
Also, let's avoid the IfOk anti-pattern ( http://wiki.c2.com/?IfOk )
here as well:
if (!fgets(buf, sizeof buf, f)) {
pr_err("fgets failed");
goto err;
}
rc = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", ...);
...
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel