From: Shraddha Barke <shraddha.6596@xxxxxxxxx> Remove explicit NULL comparison and write it in its simpler form. Signed-off-by: Shraddha Barke <shraddha.6596@xxxxxxxxx> --- drivers/staging/speakup/buffers.c | 4 ++-- drivers/staging/speakup/fakekey.c | 2 +- drivers/staging/speakup/i18n.c | 4 ++-- drivers/staging/speakup/kobjects.c | 2 +- drivers/staging/speakup/main.c | 38 +++++++++++++++++------------------ drivers/staging/speakup/selection.c | 2 +- drivers/staging/speakup/synth.c | 16 +++++++-------- drivers/staging/speakup/varhandlers.c | 6 +++--- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c index 8565c23..b055b9e 100644 --- a/drivers/staging/speakup/buffers.c +++ b/drivers/staging/speakup/buffers.c @@ -27,7 +27,7 @@ void speakup_start_ttys(void) for (i = 0; i < MAX_NR_CONSOLES; i++) { if (speakup_console[i] && speakup_console[i]->tty_stopped) continue; - if ((vc_cons[i].d != NULL) && (vc_cons[i].d->port.tty != NULL)) + if ((vc_cons[i].d) && (vc_cons[i].d->port.tty)) start_tty(vc_cons[i].d->port.tty); } } @@ -38,7 +38,7 @@ static void speakup_stop_ttys(void) int i; for (i = 0; i < MAX_NR_CONSOLES; i++) - if ((vc_cons[i].d != NULL) && (vc_cons[i].d->port.tty != NULL)) + if ((vc_cons[i].d) && (vc_cons[i].d->port.tty)) stop_tty(vc_cons[i].d->port.tty); } diff --git a/drivers/staging/speakup/fakekey.c b/drivers/staging/speakup/fakekey.c index af9b5a2..7350482 100644 --- a/drivers/staging/speakup/fakekey.c +++ b/drivers/staging/speakup/fakekey.c @@ -56,7 +56,7 @@ int speakup_add_virtual_keyboard(void) void speakup_remove_virtual_keyboard(void) { - if (virt_keyboard != NULL) { + if (virt_keyboard) { input_unregister_device(virt_keyboard); virt_keyboard = NULL; } diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c index 12f880e..470010a 100644 --- a/drivers/staging/speakup/i18n.c +++ b/drivers/staging/speakup/i18n.c @@ -410,9 +410,9 @@ static char *next_specifier(char *input) int found = 0; char *next_percent = input; - while ((next_percent != NULL) && !found) { + while ((next_percent) && !found) { next_percent = strchr(next_percent, '%'); - if (next_percent != NULL) { + if (next_percent) { /* skip over doubled percent signs */ while ((next_percent[0] == '%') && (next_percent[1] == '%')) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index fdfeb42..13b4eba 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -392,7 +392,7 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, len--; new_synth_name[len] = '\0'; spk_strlwr(new_synth_name); - if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) { + if ((synth) && (!strcmp(new_synth_name, synth->name))) { pr_warn("%s already in use\n", new_synth_name); } else if (synth_init(new_synth_name) != 0) { pr_warn("failed to init synth %s\n", new_synth_name); diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c index 456f650..9b4dab8 100644 --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c @@ -298,7 +298,7 @@ static void speakup_shut_up(struct vc_data *vc) spk_shut_up |= 0x01; spk_parked &= 0xfe; speakup_date(vc); - if (synth != NULL) + if (synth) spk_do_flush(); } @@ -440,7 +440,7 @@ static void speak_char(u_char ch) synth_printf("%s", spk_str_caps_stop); return; } - if (cp == NULL) { + if (!cp) { pr_info("speak_char: cp == NULL!\n"); return; } @@ -1150,7 +1150,7 @@ static void do_handle_shift(struct vc_data *vc, u_char value, char up_flag) { unsigned long flags; - if (synth == NULL || up_flag || spk_killed) + if (!synth || up_flag || spk_killed) return; spin_lock_irqsave(&speakup_info.spinlock, flags); if (cursor_track == read_all_mode) { @@ -1187,7 +1187,7 @@ static void do_handle_latin(struct vc_data *vc, u_char value, char up_flag) spin_unlock_irqrestore(&speakup_info.spinlock, flags); return; } - if (synth == NULL || spk_killed) { + if (!synth || spk_killed) { spin_unlock_irqrestore(&speakup_info.spinlock, flags); return; } @@ -1271,7 +1271,7 @@ void spk_reset_default_chars(void) /* First, free any non-default */ for (i = 0; i < 256; i++) { - if ((spk_characters[i] != NULL) + if ((spk_characters[i]) && (spk_characters[i] != spk_default_chars[i])) kfree(spk_characters[i]); } @@ -1313,10 +1313,10 @@ static int speakup_allocate(struct vc_data *vc) int vc_num; vc_num = vc->vc_num; - if (speakup_console[vc_num] == NULL) { + if (!speakup_console[vc_num]) { speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]), GFP_ATOMIC); - if (speakup_console[vc_num] == NULL) + if (!speakup_console[vc_num]) return -ENOMEM; speakup_date(vc); } else if (!spk_parked) @@ -1365,7 +1365,7 @@ static void kbd_fakekey2(struct vc_data *vc, int command) static void read_all_doc(struct vc_data *vc) { - if ((vc->vc_num != fg_console) || synth == NULL || spk_shut_up) + if ((vc->vc_num != fg_console) || !synth || spk_shut_up) return; if (!synth_supports_indexing()) return; @@ -1479,7 +1479,7 @@ static int pre_handle_cursor(struct vc_data *vc, u_char value, char up_flag) spin_lock_irqsave(&speakup_info.spinlock, flags); if (cursor_track == read_all_mode) { spk_parked &= 0xfe; - if (synth == NULL || up_flag || spk_shut_up) { + if (!synth || up_flag || spk_shut_up) { spin_unlock_irqrestore(&speakup_info.spinlock, flags); return NOTIFY_STOP; } @@ -1501,7 +1501,7 @@ static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag) spin_lock_irqsave(&speakup_info.spinlock, flags); spk_parked &= 0xfe; - if (synth == NULL || up_flag || spk_shut_up || cursor_track == CT_Off) { + if (!synth || up_flag || spk_shut_up || cursor_track == CT_Off) { spin_unlock_irqrestore(&speakup_info.spinlock, flags); return; } @@ -1694,7 +1694,7 @@ static void speakup_bs(struct vc_data *vc) return; if (!spk_parked) speakup_date(vc); - if (spk_shut_up || synth == NULL) { + if (spk_shut_up || !synth) { spin_unlock_irqrestore(&speakup_info.spinlock, flags); return; } @@ -1711,7 +1711,7 @@ static void speakup_con_write(struct vc_data *vc, const char *str, int len) { unsigned long flags; - if ((vc->vc_num != fg_console) || spk_shut_up || synth == NULL) + if ((vc->vc_num != fg_console) || spk_shut_up || !synth) return; if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) /* Speakup output, discard */ @@ -1740,7 +1740,7 @@ static void speakup_con_update(struct vc_data *vc) { unsigned long flags; - if (speakup_console[vc->vc_num] == NULL || spk_parked) + if (!speakup_console[vc->vc_num] || spk_parked) return; if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) /* Speakup output, discard */ @@ -1755,7 +1755,7 @@ static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag) int on_off = 2; char *label; - if (synth == NULL || up_flag || spk_killed) + if (!synth || up_flag || spk_killed) return; spin_lock_irqsave(&speakup_info.spinlock, flags); spk_shut_up &= 0xfe; @@ -1799,7 +1799,7 @@ static int inc_dec_var(u_char value) var_id = var_id / 2 + FIRST_SET_VAR; p_header = spk_get_var_header(var_id); - if (p_header == NULL) + if (!p_header) return -1; if (p_header->var_type != VAR_NUM) return -1; @@ -1880,7 +1880,7 @@ static void speakup_bits(struct vc_data *vc) { int val = this_speakup_key - (FIRST_EDIT_BITS - 1); - if (spk_special_handler != NULL || val < 1 || val > 6) { + if (spk_special_handler || val < 1 || val > 6) { synth_printf("%s\n", spk_msg_get(MSG_ERROR)); return; } @@ -1971,7 +1971,7 @@ do_goto: static void speakup_goto(struct vc_data *vc) { - if (spk_special_handler != NULL) { + if (spk_special_handler) { synth_printf("%s\n", spk_msg_get(MSG_ERROR)); return; } @@ -2049,7 +2049,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, u_char shift_info, offset; int ret = 0; - if (synth == NULL) + if (!synth) return 0; spin_lock_irqsave(&speakup_info.spinlock, flags); @@ -2119,7 +2119,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, } } no_map: - if (type == KT_SPKUP && spk_special_handler == NULL) { + if (type == KT_SPKUP && !spk_special_handler) { do_spkup(vc, new_key); spk_close_press = 0; ret = 1; diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c index aa5ab6c..cf854ad 100644 --- a/drivers/staging/speakup/selection.c +++ b/drivers/staging/speakup/selection.c @@ -172,7 +172,7 @@ static struct speakup_paste_work speakup_paste_work = { int speakup_paste_selection(struct tty_struct *tty) { - if (cmpxchg(&speakup_paste_work.tty, NULL, tty) != NULL) + if (cmpxchg(&speakup_paste_work.tty, NULL, tty)) return -EBUSY; tty_kref_get(tty); diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c index 01eddab..669d63f 100644 --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -51,7 +51,7 @@ int spk_serial_synth_probe(struct spk_synth *synth) if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) { ser = spk_serial_init(synth->ser); - if (ser == NULL) { + if (!ser) { failed = -1; } else { outb_p(0, ser->port); @@ -271,7 +271,7 @@ void spk_reset_index_count(int sc) int synth_supports_indexing(void) { - if (synth->get_index != NULL) + if (synth->get_index) return 1; return 0; } @@ -350,7 +350,7 @@ int synth_init(char *synth_name) int ret = 0; struct spk_synth *synth = NULL; - if (synth_name == NULL) + if (!synth_name) return 0; if (strcmp(synth_name, "none") == 0) { @@ -362,7 +362,7 @@ int synth_init(char *synth_name) mutex_lock(&spk_mutex); /* First, check if we already have it loaded. */ - for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++) + for (i = 0; i < MAXSYNTHS && synths[i]; i++) if (strcmp(synths[i]->name, synth_name) == 0) synth = synths[i]; @@ -421,7 +421,7 @@ void synth_release(void) struct var_t *var; unsigned long flags; - if (synth == NULL) + if (!synth) return; spin_lock_irqsave(&speakup_info.spinlock, flags); pr_info("releasing synth %s\n", synth->name); @@ -444,7 +444,7 @@ int synth_add(struct spk_synth *in_synth) int status = 0; mutex_lock(&spk_mutex); - for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++) + for (i = 0; i < MAXSYNTHS && synths[i]; i++) /* synth_remove() is responsible for rotating the array down */ if (in_synth == synths[i]) { mutex_unlock(&spk_mutex); @@ -471,11 +471,11 @@ void synth_remove(struct spk_synth *in_synth) mutex_lock(&spk_mutex); if (synth == in_synth) synth_release(); - for (i = 0; synths[i] != NULL; i++) { + for (i = 0; synths[i]; i++) { if (in_synth == synths[i]) break; } - for ( ; synths[i] != NULL; i++) /* compress table */ + for ( ; synths[i]; i++) /* compress table */ synths[i] = synths[i+1]; module_status = 0; mutex_unlock(&spk_mutex); diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c index ab4fe8d..bf81d96 100644 --- a/drivers/staging/speakup/varhandlers.c +++ b/drivers/staging/speakup/varhandlers.c @@ -98,7 +98,7 @@ void speakup_register_var(struct var_t *var) } } p_header = var_ptrs[var->var_id]; - if (p_header->data != NULL) + if (p_header->data) return; p_header->data = var; switch (p_header->var_type) { @@ -208,11 +208,11 @@ int spk_set_num_var(int input, struct st_var_header *var, int how) return -ERANGE; } var_data->u.n.value = val; - if (var->var_type == VAR_TIME && p_val != NULL) { + if (var->var_type == VAR_TIME && p_val) { *p_val = msecs_to_jiffies(val); return ret; } - if (p_val != NULL) + if (p_val) *p_val = val; if (var->var_id == PUNC_LEVEL) { spk_punc_mask = spk_punc_masks[val]; -- 2.1.4 _______________________________________________ Speakup mailing list Speakup@xxxxxxxxxxxxxxxxx http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup