Re: [rtc-linux] [PATCH 7/9] drivers/rtc: correct error-handlingcode

From: Wolfram Sang
Date: Tue Jul 28 2009 - 13:01:15 EST


On Tue, Jul 28, 2009 at 05:55:33PM +0200, Julia Lawall wrote:
>
> From: Julia Lawall <julia@xxxxxxx>
>
> This code is not executed before ds1307->rtc has been successfully
> initialized to the result of calling rtc_device_register. Thus the test
> that ds1307->rtc is not NULL is always true.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @match exists@
> expression x, E;
> statement S1, S2;
> @@
>
> x = rtc_device_register(...)
> ... when != x = E
> (
> * if (x == NULL || ...) S1 else S2
> |
> * if (x == NULL && ...) S1 else S2
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@xxxxxxx>

Acked-by: Wolfram Sang <w.sang@xxxxxxxxxxxxxx>

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |

Attachment: signature.asc
Description: Digital signature