This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Binutils Port - Infineon xc16x family.


Hi Dave,

One confusing thing is that it is not working if use "Return NULL" in
both the conditions.

  But if you remove the braces, that's the same thing as returning NULL in
both cases, and you said that that works

Actually he said that it did not work. That was the point.


What was actually happening was that in this (working but broken) code:

   static const char *
   parse_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
	    const char **strp,
	    int opindex ATTRIBUTE_UNUSED,
	    long *valuep ATTRIBUTE_UNUSED)
   {
     if (**strp == '#')
       {
         ++*strp;
         return NULL;
       }
   }

if the parse failed, a non-deterministic value was being returned, which was probably not NULL (it was probably the value of the 'cd' argument) and so the code appeared to work.


That was what confused me originally. I saw that the else.. clause had been commented out, assumed that the programmer's intention had been to return NULL in all cases and so made my change. I did not foresee the fortuitous behaviour of returning a non-NULL value which indicated an error but which was not further examined for any meaning.

Anyway, all is well now, so I will check in the revised patch.

Cheers
  Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]