Re: [PATCH V2] Fix return value from fstat calls

Tkaczyk, Mariusz
2021-08-12T06:49:29Z

Hi Nigel,
On 11.08.2021 21:09, Nigel Croxon wrote:

> + pr_err("fstat failed for %s: %s\n",devname, strerror(errno));
> + pr_err("fstat failed from %s: %s\n",fname, strerror(errno));
Typo, I guess that you want to use "for".

> + pr_err("fstat failed for %s: %s\n",dev, strerror(errno));
> + pr_err("fstat failed for %s: %s\n",devname, strerror(errno));
> + pr_err("fstat failed for %s: %s\n",devname, strerror(errno));
> + pr_err("fstat failed: %s\n", strerror(errno));
> + pr_err("fstat failed: %s\n", strerror(errno));
> + pr_err("fstat failed for %s: %s\n",devname, strerror(errno));
> + pr_err("fstat failed for %s: %s\n",devname, strerror(errno));

> + pr_err("fstat failed for %s: %s\n",devname, strerror(errno));
> + pr_err("fstat failed for %s: %s\n",devname, strerror(errno));

You are using similar error message across code. If you think that printing
error in this case is worth to be added then please define wrapper for fstat
with error message and use that.
Current solution is typo friendly (and I found one) and breaks DNRY rule.
Any modern C IDE is able to find references- result is same as in search via
string in case of error.

Mariusz