Vinson,

I'm not sure its hugely useful to silence warnings in this way -- the
new code is equivalent to the old in that the return value from fgets is
just being discarded.  Looking at the man page for fgets, it returns
NULL on EOF or error. We're already checking for eof, so one way of
interpreting the warning is that the call to feof() is redundant and
could be removed, as in:

   while(fgets(line, sizeof(line), f) != NULL) {
       if (line[0]) {
          ...

I've also removed the second call to feof() -- that one really does look
like a bug, because we would read the last line of the file, then
discard it as the second feof() would fail...

Anyway - the point is the warning did have some relevence - it was
flagging up some messy code and a bit of investigation unearthed a
potentially real bug.  

A lot of warnings are just bogus noise, but sometimes they really do
point at bad code and it's worth investigating before silencing the
warning...

Keith

On Tue, 2009-12-29 at 21:12 -0800, Vinson Lee wrote:
> Module: Mesa
> Branch: mesa_7_7_branch
> Commit: 0ab29d2b35bff913818f34d1979295a98cbe2b71
> URL:    
> http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ab29d2b35bff913818f34d1979295a98cbe2b71
> 
> Author: Vinson Lee <v...@vmware.com>
> Date:   Tue Dec 29 21:11:37 2009 -0800
> 
> progs/glsl: Silence compiler warnings.
> 
> ---
> 
>  progs/glsl/shtest.c   |    4 +++-
>  progs/glsl/vert-tex.c |    9 ---------
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/progs/glsl/shtest.c b/progs/glsl/shtest.c
> index 88315d7..3c79543 100644
> --- a/progs/glsl/shtest.c
> +++ b/progs/glsl/shtest.c
> @@ -493,7 +493,9 @@ ReadConfigFile(const char *filename, struct config_file 
> *conf)
>  
>     /* ugly but functional parser */
>     while (!feof(f)) {
> -      fgets(line, sizeof(line), f);
> +      char *result;
> +      result = fgets(line, sizeof(line), f);
> +      (void) result;
>        if (!feof(f) && line[0]) {
>           if (strncmp(line, "vs ", 3) == 0) {
>              VertShaderFile = strdup(line + 3);
> diff --git a/progs/glsl/vert-tex.c b/progs/glsl/vert-tex.c
> index 4c8bfa5..2b93c78 100644
> --- a/progs/glsl/vert-tex.c
> +++ b/progs/glsl/vert-tex.c
> @@ -40,15 +40,6 @@ static GLboolean Anim = GL_TRUE;
>  static GLboolean WireFrame = GL_TRUE;
>  static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f;
>  
> -
> -/* value[0] = tex unit */
> -static struct uniform_info Uniforms[] = {
> -   { "tex1",  1, GL_SAMPLER_2D, { 0, 0, 0, 0 }, -1 },
> -   END_OF_UNIFORMS
> -};
> -
> -
> -
>  static void
>  Idle(void)
>  {
> 
> _______________________________________________
> mesa-commit mailing list
> mesa-com...@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-commit



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to