Skip to contentSkip to conversation

tty: serial/68328serial.c: remove unnecessary null pointer check

PATCH New Cong Ding 3 participants 4 messages Jan 16, 2013 – Jan 20, 2013 TTY layer and serial drivers

lore
Share & tools
lore
author
#1 lore raw

PATCH 1/1 tty: serial/crisv10.c: remove unnecessary null pointer check

In reply to Cong Ding

The pointer tty is dereferened in line 3135, so it is not necessary to check null again in line 3140.

---
 drivers/tty/serial/crisv10.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/crisv10.c +1 -1
index 35ee6a2..3b24965 100644
@@ -3137,7 +3137,7 @@ static int rs_raw_write(struct tty_struct *tty,
 
 	/* first some sanity checks */
 
-	if (!tty || !info->xmit.buf)
+	if (!info->xmit.buf)
 		return 0;
 
 #ifdef SERIAL_DEBUG_DATA
Signature · 1 line
1.7.10.4

Cong Ding

author
#0 lore raw

PATCH 1/1 tty: serial/68328serial.c: remove unnecessary null pointer check

The pointer info is dereferened in line 1009, so it is not necessary to check null again in line 1012.

---
 drivers/tty/serial/68328serial.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/68328serial.c +1 -1
index f99a845..4f7c0d2 100644
@@ -1009,7 +1009,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 	m68328_uart *uart = &uart_addr[info->line];
 	unsigned long flags;
 
-	if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
+	if (serial_paranoia_check(info, tty->name, "rs_close"))
 		return;
 	
 	local_irq_save(flags);
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH] tty: serial/crisv10.c: remove unnecessary null pointer check

In reply to Cong Ding
Quoted 2 lines · Cong Ding

The pointer tty is dereferened in line 3135, so it is not necessary to check null again in line 3140.

I don't know if we actually need to check the parameter tty from being null, but when checking the rest of the file, most other functions don't check it.

In any case, gcc is quite likely to remove that check due to the earlier dereference, so removing it is probably acceptable.

Quoted 1 line

Thanks, I'll take it in the CRIS tree.

/^JN - Jesper Nilsson

Signature · 1 line
               Jesper Nilsson -- [email protected]
#3 lore raw

Re: [PATCH] tty: serial/crisv10.c: remove unnecessary null pointer check

Quoted 6 lines · Jesper Nilsson
Quoted 2 lines · Cong Ding

The pointer tty is dereferened in line 3135, so it is not necessary to check null again in line 3140.

I don't know if we actually need to check the parameter tty from being null, but when checking the rest of the file, most other functions don't check it.

Yes, the check in unneeded.

thanks,

Signature · 2 lines
js
suse labs