Interesting C question

From: Sellam Ismail <foo_at_siconic.com>
Date: Wed Feb 6 02:08:15 2002

On Wed, 6 Feb 2002, Cini, Richard wrote:

> In the body of the routine, the variable can be set to three values
> using #defines from the header. For some reason, the variable is not being
> set to the #define value. As you trace execution, the variable to be
> returned by the routine remains 0xcccccccc after assignment:
>
> nSioStatus = SIO_WDB ; //#defines to 0x80

So you're saying if you added a printf("%x", nSioStatus) right here (after
the assignment) you'd see 0xcccccccc?

> So, I initialized the variable to 0 and for good measure, returned
> the int as:
>
> return (nSioStatus & 0xff) ;
>
> In one of the top calling routines, it gets truncated to a BYTE-size
> (so to speak) anyway.

Maybe because you are returning effectively a byte? Try type-casting the
returned value:

return ((int)(nSioStatus & 0xff));

I don't know if that actually addresses your main problem directly.

I also like Bryan's suggestion to check for out-of-bounds writes on a
malloc'd memory buffer. That sort of thing causes really weird shit to
happen.

Sellam Ismail Vintage Computer Festival
------------------------------------------------------------------------------
International Man of Intrigue and Danger http://www.vintage.org

 * Old computing resources for business and academia at www.VintageTech.com *
Received on Wed Feb 06 2002 - 02:08:15 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:34:44 BST