From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751984AbZG0QQJ (ORCPT ); Mon, 27 Jul 2009 12:16:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751253AbZG0QQI (ORCPT ); Mon, 27 Jul 2009 12:16:08 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:40661 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750756AbZG0QQG (ORCPT ); Mon, 27 Jul 2009 12:16:06 -0400 Date: Mon, 27 Jul 2009 18:12:53 +0200 (CEST) From: Julia Lawall To: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 2/12] drivers/char: Correct redundant test Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julia Lawall dc was tested for NULL at the beginning of the function, in which case the function returns. dc does not seem to be updated in the meantime, so the second test is unnecessary. I have assumed that the comment, "notify card" goes with the code below it. A simplified version of the semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; expression E; @@ if (x@ == NULL || ...) { ... when forall return ...; } ... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\) ( *x == NULL | *x != NULL ) // Signed-off-by: Julia Lawall --- drivers/char/nozomi.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c index ec58d8c..9322fec 100644 --- a/drivers/char/nozomi.c +++ b/drivers/char/nozomi.c @@ -1675,11 +1675,6 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, rval = __kfifo_put(port->fifo_ul, (unsigned char *)buffer, count); /* notify card */ - if (unlikely(dc == NULL)) { - DBG1("No device context?"); - goto exit; - } - spin_lock_irqsave(&dc->spin_mutex, flags); /* CTS is only valid on the modem channel */ if (port == &(dc->port[PORT_MDM])) {