staging: dgnc: remove redundant NULL checks in
Subsystems (2)
PATCH RESEND 1/15 staging: dgnc: remove redundant NULL checks in
The dgnc_block_til_ready() is only used in dgnc_tty_open().
The unit data(struct un_t) was stored into tty->driver_data in dgnc_tty_open(). And also tty and un were tested about NULL so these variables doesn't need to check for NULL in dgnc_block_til_ready().
---
This patch seems to be missed for a long time.
I resend this patch without any updates.
drivers/staging/dgnc/dgnc_tty.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/staging/dgnc/dgnc_tty.c +2 -7
@@ -1172,17 +1172,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct channel_t *ch) {int retval =0 ; -struct un_t *un =NULL ; +struct un_t *un = tty->driver_data;unsigned long flags;uint old_flags =0 ;int sleep_on_un_flags =0 ; -if (!tty || tty->magic !=TTY_MAGIC || !file || !ch || - ch->magic !=DGNC_CHANNEL_MAGIC ) -return -ENXIO ; - - un = tty->driver_data; -if (!un || un->magic !=DGNC_UNIT_MAGIC ) +if (!file)return -ENXIO ;spin_lock_irqsave (&ch->ch_lock, flags);
Signature · 1 line
1.9.1
2016-07-04 20:36 GMT+09:00 Daeseok Youn <[email protected]>:
Quoted 38 lines
The
dgnc_block_til_ready()is only used indgnc_tty_open().
The unitdata(struct un_t)was stored intotty->driver_dataindgnc_tty_open(). And also tty and un were tested about NULL so these variables doesn't need to check for NULL indgnc_block_til_ready().Signed-off-by Daeseok Youn <[email protected]>---
This patch seems to be missed for a long time.
I resend this patch without any updates.drivers/staging/dgnc/dgnc_tty.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)drivers/staging/dgnc/dgnc_tty.c +2
-8@@ -1172,17 +1172,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct channel_t *ch) {int retval =0 ; -struct un_t *un =NULL ; +struct un_t *un = tty->driver_data;unsigned long flags;uint old_flags =0 ;int sleep_on_un_flags =0 ; -if (!tty || tty->magic !=TTY_MAGIC || !file || !ch || - ch->magic !=DGNC_CHANNEL_MAGIC ) -return -ENXIO ; - - un = tty->driver_data; -if (!un || un->magic !=DGNC_UNIT_MAGIC ) +if (!file)return -ENXIO ;spin_lock_irqsave (&ch->ch_lock, flags); --
Quoted 2 lines
1.9.1
This patch will be sent again, I made a mistake while gathering my previous patches which didn't accepted for a long time. Sorry for noise.
Thanks.
Regards,
Jake.
Quoted 28 lines · Daeseok Youn
The
dgnc_block_til_ready()is only used indgnc_tty_open().
The unitdata(struct un_t)was stored intotty->driver_dataindgnc_tty_open(). And also tty and un were tested about NULL so these variables doesn't need to check for NULL indgnc_block_til_ready().Signed-off-by Daeseok Youn <[email protected]>---
This patch seems to be missed for a long time.
I resend this patch without any updates.drivers/staging/dgnc/dgnc_tty.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)drivers/staging/dgnc/dgnc_tty.c +1
-1@@ -1172,17 +1172,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct channel_t *ch) {int retval =0 ; -struct un_t *un =NULL ; +struct un_t *un = tty->driver_data;unsigned long flags;uint old_flags =0 ;int sleep_on_un_flags =0 ;
drivers/staging/dgnc/dgnc_tty.c static int dgnc_block_til_ready(struct tty_struct *tty, · line 1183
Quoted 10 lines
drivers/staging/dgnc/dgnc_tty.c +1
-6-if (!tty || tty->magic !=TTY_MAGIC || !file || !ch || - ch->magic !=DGNC_CHANNEL_MAGIC ) -return -ENXIO ; - - un = tty->driver_data; -if (!un || un->magic !=DGNC_UNIT_MAGIC ) +if (!file)return -ENXIO ;spin_lock_irqsave (&ch->ch_lock, flags);
Hi,
Just curious. Are you confident of removing the tty->magic != TTY_MAGIC check?
From what I've seen that one can catch potential errors. I might be wrong.
Thanks,
Luis