On Sun, May 20, 2018 at 03:18:14PM +0200, Hiltjo Posthuma wrote:
> On Sun, May 20, 2018 at 02:21:36PM +0200, David Demelier wrote:
> > +const char *
> > +backlight_perc(const char *card)
> > +{
> > + char path[PATH_MAX];
> > + int max, cur;
> > +
> > + if (esnprintf(path, sizeof (path), BRIGHTNESS_MAX, card) < 0 ||
> > + pscanf(path, "%d", &max) < 0) {
> > + return NULL;
> > + }
> > +
>
> Check for pscanf != 1 here.
Done and done.
> Maybe check for division by zero (max) here.
Good catch, what do you recommend if max is 0? Resetting to 100? Or to return
NULL to indicate an error?
Kind regards,
--
David
Received on Sun May 20 2018 - 16:48:14 CEST