Le 14/06/2016 à 11:34, Peter Maydell a écrit :
> On 22 May 2016 at 17:56, Laurent Vivier <laur...@vivier.eu> wrote:
>> rtnetlink is needed to use iproute package (ip addr, ip route)
>> and dhcp client.
>>
>> +static abi_long target_to_host_for_each_nlmsg(struct nlmsghdr *nlh,
>> +                                              size_t len,
>> +                                              abi_long 
>> (*target_to_host_nlmsg)
>> +                                                       (struct nlmsghdr *))
>> +{
>> +    int ret;
>> +
>> +    while (len > sizeof(struct nlmsghdr)) {
>> +        if (tswap32(nlh->nlmsg_len) < sizeof(struct nlmsghdr) ||
>> +            tswap32(nlh->nlmsg_len) > len) {
>> +            break;
>> +        }
>> +        tswap_nlmsghdr(nlh);
>> +        switch (nlh->nlmsg_type) {
>> +        case NLMSG_DONE:
>> +            return 0;
>> +        case NLMSG_NOOP:
>> +            break;
>> +        case NLMSG_ERROR:
>> +        {
>> +            struct nlmsgerr *e = NLMSG_DATA(nlh);
>> +            e->error = tswap32(e->error);
>> +            tswap_nlmsghdr(&e->msg);
>> +        }
>> +        default:
>> +            ret = target_to_host_nlmsg(nlh);
>> +            if (ret < 0) {
>> +                return ret;
>> +            }
>> +        }
> 
> Coverity points out that the NLMSG_ERROR case falls
> through into the default. Missing "break" or missing
> "/* fallthrough */" comment?

I think like in host_to_target_for_each_nlmsg() we need:

        case NLMSG_ERROR:
        {
            struct nlmsgerr *e = NLMSG_DATA(nlh);
            e->error = tswap32(e->error);
            tswap_nlmsghdr(&e->msg);
            tswap_nlmsghdr(nlh);
            return 0;
        }

I'm going to have a deeper look at this and send a patch.

Thanks,
Laurent

Reply via email to