Changeset 6dbbd277 in rtems for cpukit/dtc


Ignore:
Timestamp:
Feb 23, 2017, 11:51:05 PM (3 years ago)
Author:
David Gibson <david@…>
Branches:
master
Children:
90f54b0e
Parents:
8cd96f47
git-author:
David Gibson <david@…> (02/23/17 23:51:05)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/19/18 05:01:10)
Message:

libfdt: Remove undefined behaviour setting empty properties

The standard way of setting an empty property using libfdt is:

fdt_setprop(fdt, nodeoffset, propname, NULL, 0);

However, the implementation of this includes an unconditional:

memcpy(prop->data, NULL, 0);

Which although it will be a no-op (which is what we want) on many platforms
is technically undefined behaviour. Correct this, so that when passing
a 0 length, passing a NULL pointer as the value to fdt_setprop() is
definitely safe. This should quiet static checkers which complain about
this.

Signed-off-by: David Gibson <david@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dtc/libfdt/fdt_rw.c

    r8cd96f47 r6dbbd277  
    284284                return err;
    285285
    286         memcpy(prop->data, val, len);
     286        if (len)
     287                memcpy(prop->data, val, len);
    287288        return 0;
    288289}
Note: See TracChangeset for help on using the changeset viewer.