[ovs-discuss] [PATCH 03/20] netdev: Change netdev_get_etheraddr() to return an error code.

Ben Pfaff blp at nicira.com
Tue Jul 28 13:44:37 PDT 2009


Justin Pettit <jpettit at nicira.com> writes:

> On Jul 24, 2009, at 2:19 PM, Ben Pfaff wrote:
>
>> -/* Returns a pointer to 'netdev''s MAC address.  The caller must
>> not modify or
>> - * free the returned buffer. */
>> -const uint8_t *
>> -netdev_get_etheraddr(const struct netdev *netdev)
>> +/* Retrieves 'netdev''s MAC address.  If successful, returns 0 and
>> copies the
>> + * the MAC address into 'mac'.  On failure, returns a positive
>> errno value and
>> + * clears 'mac' to all-zeros. */
>> +int
>> +netdev_get_etheraddr(const struct netdev *netdev, uint8_t
>> mac[ETH_ADDR_LEN])
>> {
>> -    return netdev->etheraddr;
>> +    memcpy(mac, netdev->etheraddr, ETH_ADDR_LEN);
>> +    return 0;
>> }
>
> I don't believe this code is behaving as the comment describes.
> Otherwise, the commit looks good.

OK, I added this to the commit message, also to the messages for
netdev_get_mtu() and netdev_get_in4():

    (Currently netdev_get_etheraddr() won't ever return an error, but other
    future implementations might.)




More information about the discuss mailing list