[ovs-dev] [PATCH 1/2] vswitchd: Add miimon support.

Ethan Jackson ethan at nicira.com
Thu Jan 13 01:01:33 UTC 2011


Oh interesting.  Didn't cause warnings for me.  I'll submit a patch.

Ethan

On Wed, Jan 12, 2011 at 4:55 PM, Jesse Gross <jesse at nicira.com> wrote:
> On Wed, Jan 12, 2011 at 6:27 PM, Ethan Jackson <ethan at nicira.com> wrote:
>> diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
>> index 97f9a64..8333bf5 100644
>> --- a/lib/netdev-linux.c
>> +++ b/lib/netdev-linux.c
> [...]
>> +static int
>> +netdev_linux_get_miimon(const struct netdev *netdev_, bool *miimon)
>> +{
>> +    int error;
>> +    struct ifreq ifr;
>> +    const char *name = netdev_get_name(netdev_);
>> +
>> +    *miimon = false;
>> +    memset(&ifr, 0, sizeof ifr);
>> +
>> +    error = netdev_linux_do_ioctl(name, &ifr, SIOCGMIIPHY, "SIOCGMIIPHY");
>> +    if (!error) {
>> +        struct mii_ioctl_data *data = (struct mii_ioctl_data *)&ifr.ifr_data;
>> +
>> +        data->reg_num = MII_BMSR;
>> +        error = netdev_linux_do_ioctl(name, &ifr, SIOCGMIIREG, "SIOCGMIIREG");
>> +
>> +        if (!error) {
>> +            *miimon = !!(data->val_out & BMSR_LSTATUS);
>
> This causes new warnings for me:
> lib/netdev-linux.c: In function ‘netdev_linux_get_miimon’:
> lib/netdev-linux.c:1030: warning: dereferencing pointer ‘data’ does
> break strict-aliasing rules
> lib/netdev-linux.c:1026: warning: dereferencing pointer ‘data’ does
> break strict-aliasing rules
> lib/netdev-linux.c:1023: note: initialized from here
> lib/netdev-linux.c:1045: warning: dereferencing pointer ‘eval’ does
> break strict-aliasing rules
> lib/netdev-linux.c:1036: note: initialized from here
>
> You're not allowed to have dereferenced data with two different types.
>  In this case, the compiler would be within its rights to optimize out
> the assignment to data->reg_num, since from its perspective nothing
> ever uses it.
>




More information about the dev mailing list