Hello.

Raster or anyone else worked with this code please review if this patch 
jumps to the right places for error handling. Especially if we want to 
continue reading other sources after a fgets error. I would think so but 
some other eyes would help.

regards
Stefan Schmidt
On 06/12/2012 11:01 AM, Enlightenment SVN wrote:
> Log:
> e/modules/cpufreq: Check the return of fgets to make sure we operate on 
> something sane
>
>    If we get NULL as reply here the buf will not contain the stuff we are 
> looking for.
>
> Author:       stefan
> Date:         2012-06-12 03:01:56 -0700 (Tue, 12 Jun 2012)
> New Revision: 72005
> Trac:         http://trac.enlightenment.org/e/changeset/72005
>
> Modified:
>    trunk/e/src/modules/cpufreq/e_mod_main.c
>
> Modified: trunk/e/src/modules/cpufreq/e_mod_main.c
> ===================================================================
> --- trunk/e/src/modules/cpufreq/e_mod_main.c  2012-06-12 10:01:22 UTC (rev 
> 72004)
> +++ trunk/e/src/modules/cpufreq/e_mod_main.c  2012-06-12 10:01:56 UTC (rev 
> 72005)
> @@ -604,7 +604,7 @@
>            s->frequencies = NULL;
>         }
>
> -     fgets(buf, sizeof(buf), f);
> +     if (fgets(buf, sizeof(buf), f) == NULL) return 1;
>       buf[sizeof(buf) - 1] = 0;
>       fclose(f);
>
> @@ -638,7 +638,7 @@
>            s->governors = NULL;
>         }
>
> -     fgets(buf, sizeof(buf), f);
> +     if (fgets(buf, sizeof(buf), f) == NULL) return 1;
>       buf[sizeof(buf) - 1] = 0;
>       fclose(f);
>
> @@ -698,7 +698,7 @@
>         f = fopen(buf, "r");
>         if (f)
>           {
> -          fgets(buf, sizeof(buf), f);
> +          if (fgets(buf, sizeof(buf), f) == NULL) continue;
>             buf[sizeof(buf) - 1] = 0;
>             fclose(f);
>
> @@ -740,7 +740,7 @@
>           char *p;
>
>           buf[0] = 0;
> -     fgets(buf, sizeof(buf), f);
> +     if (fgets(buf, sizeof(buf), f) ==  NULL) return ret;;
>       buf[sizeof(buf) - 1] = 0;
>       fclose(f);
>           for (p = buf; (*p != 0)&&  (isalnum(*p)); p++);

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to