qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH qemu v2] spapr: Kill SLOF


From: David Gibson
Subject: Re: [PATCH qemu v2] spapr: Kill SLOF
Date: Tue, 7 Jan 2020 10:56:04 +1100

On Tue, Jan 07, 2020 at 12:39:42AM +1100, Alexey Kardashevskiy wrote:
> 
> 
> On 06/01/2020 15:19, David Gibson wrote:
> 
> > > +    const struct fdt_property *prop;
> > > +    const char *tmp;
> > > +
> > > +    readstr(prevaddr, prev);
> > > +    for (offset = fdt_first_property_offset(fdt, offset);
> > > +         (offset >= 0);
> > > +         (offset = fdt_next_property_offset(fdt, offset))) {
> > > +
> > > +        prop = fdt_get_property_by_offset(fdt, offset, &namelen);
> > 
> > fdt_getprop_by_offset() also returns the property's name without
> > having to dick around with fdt_get_string() manually.
> 
> 
> btw I looked quickly:
> 
> const void *fdt_getprop_by_offset(const void *fdt, int offset,
>                   const char **namep, int *lenp)
> {
>     const struct fdt_property *prop;
> 
>     prop = fdt_get_property_by_offset_(fdt, offset, lenp);
>     if (!prop)
>         return NULL;
>     if (namep) {
>         const char *name;
>         int namelen;
>         name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff),
>                       &namelen);
>         if (!name) {
>             if (lenp)
>                 *lenp = namelen;
>             return NULL;
>         }
>         *namep = name;
>     }
> 
>     /* Handle realignment */
>     if (fdt_version(fdt) < 0x10 && (offset + sizeof(*prop)) % 8 &&
>         fdt32_ld(&prop->len) >= 8)
>         return prop->data + 4;
>     return prop->data;
> }
> 
> 
> and incorrectly assumed *lenp is the name length because of "*lenp =
> namelen". Huh :)

Ah, yeah, that is a bit confusing, but I don't see a way to improve
it.  That's the error case, in which case both *lenp and namelen are
carrying an error code, not their usual value.

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]