On Wed, May 23, 2018 at 1:08 PM, Ben Pfaff <[email protected]> wrote:
>
> On Sat, May 19, 2018 at 02:25:05PM -0700, Han Zhou wrote:
> > ovn-controller abort was found in pinctrl_run() when debugging
> > an occasional test case failure of:
> > ovn-controller.at: Chassis external-id
>
> Thanks for finding the problem.
>
> I don't think that this is actually the right solution though:
>
> ../ovn/controller/pinctrl.c:131:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:147:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:163:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:390:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:684:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:881:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:1454:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:1923:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
> ../ovn/controller/pinctrl.c:2401:17: error: comparison of unsigned
enum expression < 0 is always false [-Werror,-Wtautological-compare]
Interesting. My gcc may be too old to report this error.
$ gcc --version
gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
It doesn't even support the -Wautological-compare option.
Then I changed to another one:
$ gcc --version
gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
This version supports -Wautological-compare, but it still doesn't report
any problem, even if I add it to Makefile directly.
Could you tell which compiler/version you are using?
Anyway, I agree this is a real problem. Assigning negative value to a
non-negative enum do result in unexpected behavior, since compiler
optimizes if-conditions without doing the comparison in this case. I
experimented with a small piece of code, and the results are the same on
both versions of the gcc:
=======================
#include <stdio.h>
enum xxx {
A = 1
};
int main()
{
enum xxx x = -1;
if (x < 0) {
printf("x < 0\n");
} else {
printf("x > 0\n");
}
printf("x=%d\n", x);
}
=======================
Result:
$ ./enum
x > 0
x=-1
I submitted v2 here: https://patchwork.ozlabs.org/patch/919434/
Thanks,
Han
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev