Re: [PATCH] OF: DT-Overlay configfs interface (v3)

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

 




Hi Geert,

> On May 13, 2015, at 17:40 , Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> 
> Hi Pantelis,
> 
> On Wed, Dec 3, 2014 at 12:23 PM, Pantelis Antoniou
> <pantelis.antoniou@xxxxxxxxxxxx> wrote:
>> diff --git a/drivers/of/configfs.c b/drivers/of/configfs.c
>> new file mode 100644
>> index 0000000..1434ade
>> --- /dev/null
>> +++ b/drivers/of/configfs.c
>> @@ -0,0 +1,332 @@
> 
>> +static int create_overlay(struct cfs_overlay_item *overlay, void *blob)
> 
> After "[PATCH] of/fdt: Make fdt blob input parameters of unflatten functions
> const", you can make blob const ... (continue below) …
> 

Yes, seen it, thanks.

>> +{
> 
> [...]
> 
>> +static ssize_t cfs_overlay_item_path_store(struct cfs_overlay_item *overlay,
>> +               const char *page, size_t count)
>> +{
>> +       const char *p = page;
>> +       char *s;
>> +       int err;
>> +
>> +       /* if it's set do not allow changes */
>> +       if (overlay->path[0] != '\0' || overlay->dtbo_size > 0)
>> +               return -EPERM;
>> +
>> +       /* copy to path buffer (and make sure it's always zero terminated */
>> +       count = snprintf(overlay->path, sizeof(overlay->path) - 1, "%s", p);
>> +       overlay->path[sizeof(overlay->path) - 1] = '\0';
> 
> snprintf() always zero-terminates the destination buffer, so you can just do
> 
>        count = snprintf(overlay->path, sizeof(overlay->path), "%s", p);
> 
> You may want to check if count >= sizeofoverlay->path), to catch truncation.
> 

Hmm, good catch. The manual zero termination is just a habit I carried from
user-space programming.

>> +
>> +       /* strip trailing newlines */
>> +       s = overlay->path + strlen(overlay->path);
>> +       while (s > overlay->path && *--s == '\n')
>> +               *s = '\0';
>> +
>> +       pr_debug("%s: path is '%s'\n", __func__, overlay->path);
>> +
>> +       err = request_firmware(&overlay->fw, overlay->path, NULL);
>> +       if (err != 0)
>> +               goto out_err;
>> +
>> +       err = create_overlay(overlay, (void *)overlay->fw->data);
> 
> ... (continuation) ... and drop the cast.
> 

OK

> Gr{oetje,eeting}s,
> 
>                        Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                -- Linus Torvalds

Regards

— Pantelis

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux