This email didn't make the list so I'm sending it again.

Paul

---------- Forwarded message ----------
From: Paul Cochrane <[EMAIL PROTECTED]>
Date: 29 Oct 2007 15:36
Subject: Re: [svn:parrot] r22585 - trunk/src
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]


On 29/10/2007, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Author: particle
> Date: Mon Oct 29 05:59:52 2007
> New Revision: 22585
>
> Modified:
>    trunk/src/debug.c
>    trunk/src/inter_create.c
>
> Log:
> casting to avoid warnings
>
> Modified: trunk/src/debug.c
> ==============================================================================
> --- trunk/src/debug.c   (original)
> +++ trunk/src/debug.c   Mon Oct 29 05:59:52 2007
> @@ -335,7 +335,7 @@
>
>      /* Nonempty and did not start with a letter */
>      if (c == 0)
> -        c = -1;
> +        c = (unsigned long)-1;
>
>      *cmdP = c;
>
> @@ -411,7 +411,7 @@
>
>      /* generate string (no more than 255 chars) */
>      while (ch != EOF && ch != '\n' && (i < 255)) {
> -        c[i++] = ch;
> +        c[i++] = (char)ch;
>          ch     = fgetc(stdin);
>      }
>
> @@ -733,7 +733,7 @@
>      }
>
>      /* get the register number */
> -    condition->reg = atoi(++command);
> +    condition->reg = (unsigned char)atoi(++command);
>
>      /* the next argument might have no spaces between the register and the
>       * condition. */
>
> Modified: trunk/src/inter_create.c
> ==============================================================================
> --- trunk/src/inter_create.c    (original)
> +++ trunk/src/inter_create.c    Mon Oct 29 05:59:52 2007
> @@ -135,7 +135,7 @@
>      create_initial_context(interp);
>      interp->resume_flag = RESUME_INITIAL;
>      /* main is called as a Sub too - this will get depth 0 then */
> -    CONTEXT(interp->ctx)->recursion_depth = -1;
> +    CONTEXT(interp->ctx)->recursion_depth = (UINTVAL)-1;
>      interp->recursion_limit = RECURSION_LIMIT;
>

Does casting -1 to unint make any sense?  It looks here like if
recursion depth has a negative number then something has gone wrong
(in which case I don't know why it was declared unsigned int to begin
with).  I've seen these errors/warnings for a while and wondered
whether or not to make the cast, but I believe there is a deeper
problem.  Why are we wanting to assign -1 to recursion_depth to start
with?  This is also the case where the variable 'c' is set to -1
above.  'c' is ostensibly a character, so why is it being set to -1?
I agree with getting rid of the warnings (there many others which need
attention) but I think we should get rid of them in the right way (and
yes, I do realise this is *me* the one who writes terrible C code
talking here ;-)  ).

Paul

Reply via email to