This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils 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: [PATCH] Support AArch64 architecture


Mark Wielaard <mjw@redhat.com> writes:

>> diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
>> +  ssize_t
>> +  regtype (const char *setname, int type, const char *fmt, int arg)
>> +  {
>> +    *setnamep = setname;
>> +    *typep = type;
>> +    int s = snprintf (name, namelen, fmt, arg);
>> +    if (s > 0 && (unsigned) s >= namelen)
>> +      s = -1;
>
> I would have expected if (s < 0 || (unsigned) s >= namelen)
> to signal a snprintf error.
>
>> +    return s + 1;
>> +  }
>
> So if there is an error (given name array is too short?) then
> s = -1 + 1 = 0. But that looks like an unused register number.

D'oh, right.  I changed it to return s+1, which makes it a success
path.  I'll change it to:

        if (s < 0 || (unsigned) s >= namelen)
          return -1;
        return s + 1;

... as you propose.

Thanks,
PM

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