Re: [PATCH] telephony/ixj: Fix warning about sequence points

From: Andrew Morton
Date: Thu Mar 22 2012 - 19:03:35 EST


On Mon, 19 Mar 2012 11:57:44 +0100
Uwe Kleine-K__nig <uwe@xxxxxxxxxxxxxxxxx> wrote:

> In the statement
>
> j->caplist[j->caps].handle = j->caps++;
>
> there is no sequence point between the usage of j->caps on the LHS of the
> assignment and the incrementation on its RHS. So it's not defined in Standard C
> if j->caps is already incremented when used on the LHS even though the postfix
> ++ operator is used. To properly fix that the incrementation has to be done in
> a seperate expression.
>
> This fixes:
> drivers/telephony/ixj.c: In function ___add_caps___:
> drivers/telephony/ixj.c:5930:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:5950:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:5954:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:5965:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:5976:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:5988:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:5998:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6003:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6008:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6013:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6019:38: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6026:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6031:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6036:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6041:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6049:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6057:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6065:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
> drivers/telephony/ixj.c:6071:39: warning: operation on ___j->caps___ may be undefined [-Wsequence-point]
>
> Signed-off-by: Uwe Kleine-K__nig <uwe@xxxxxxxxxxxxxxxxx>
> ---
> drivers/telephony/ixj.c | 57 +++++++++++++++++++++++++++++++---------------

fyi, ixj.c has been moved into staging/, with a view to removing it
altogether.

It will be sad to see it go - it has stood as a great example of what not
to do ;) And no, I don't now how to find out if anyone is using it either.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/