[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please test new SILO

Am Sonntag, 4. Juni 2006 19:09 schrieb Jurij Smakov:
> On Sun, 4 Jun 2006, Hendrik Sattler wrote:
> > Am Sonntag, 4. Juni 2006 12:20 schrieb Josip Rodin:
> >> That's one funky patch. The previous version of the variable wasn't
> >> getting null-terminated?
> >
> > A const string is always null-terminated. Maybe the problem was with it
> > being const?
> Right, AFAICT the compiler was assuming that buffer is const. Later in the
> code it is used to retrieve the architecture string from the PROM, and the
> buffer[4] char then determines the arch. With the const assumption this
> value was incorrectly set to 'c' at compile time, leading to misdetection
> of the architecture.

Actually, declaring it as
char buffer[8] = "sun4c";
would be better.

And you should use sizeof(buffer) as the last argument for prom_getproperty().
Not that if that function return -1, e.g. because the buffer is too small, it 
will always hit the sun4c case instead of the default case.
It should also be checked, that the strlen(buffer) is  >=5  and i is not -1 
before testing buffer[4].


Reply to: