> -----Original Message----- > From: Dan Carpenter [mailto:dan.carpenter@xxxxxxxxxx] > Subject: Re: [bug report] IB/mlx5: Respect mlx5_core reserved GIDs > > On Thu, Jul 06, 2017 at 02:47:33PM +0300, Leon Romanovsky wrote: > > > > It works by chance, assuming that "->raw" will be always first member is > > not a good strategy, so I agree with Dan. It is NULL dereferencing. > > > > How these false positives normally look is like this: > > struct whatever *p = foo->bar; > > if (!foo) > return -EINVAL; > > It looks like a dereference but isn't. And in this case it doesn't > matter if it's the first member or not. > > Anyway, just from a correctness point of view it's better to not print > false positives. > Dan, After taking another look, I am now sure this is a false positive, and the existing code is OK and should not change. Do note that this is a pointer to a union, not to a struct! So the -> operator performs a cast, not a dereference. Also, it doesn't matter if it's a first member or not as all members of a union are at the same pointer. Do you think smatch static checker needs a fix? Ilan. ��.n��������+%������w��{.n�����{���fk��ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f