Skip to contentSkip to conversation

staging: speakup: kobjects: Delete comparison

PATCH In review Tamara Diaconita 3 participants 3 messages Mar 7, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: speakup: kobjects: Delete comparison

Delete comparison in 'if' structure to fix the checkpath.pl issue:
CHECK: Comparison to NULL could be written 'synth'.

Comparison to NULL is not necessary because 'if' structure tests if 'synth' is NULL anyway.

---
 drivers/staging/speakup/kobjects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +1 -1
index ac6ed8b..0cd5384 100644
@@ -391,7 +391,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);
Signature · 1 line
2.9.3
#1 lore raw
Quoted 5 lines · Tamara Diaconita

Delete comparison in 'if' structure to fix the checkpath.pl issue:
CHECK: Comparison to NULL could be written 'synth'.

Comparison to NULL is not necessary because 'if' structure tests if 'synth' is NULL anyway.

This explanation should be placed before mentioning checkpatch.pl.

The commit message shouldn't focus on the error reported by checkpatch, but mostly on why this patch is needed.

After, you explain this you can add a mention that it was discovered using checkpatch :).

Quoted 11 lines
---
 drivers/staging/speakup/kobjects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +0 -0
index ac6ed8b..0cd5384 100644

drivers/staging/speakup/kobjects.c static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, · line 395

Quoted 6 lines
drivers/staging/speakup/kobjects.c +1 -1
@@ -391,7 +391,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);

At this point you can remove the parenthesis (synth) -> synth

Quoted 2 lines
drivers/staging/speakup/kobjects.c +0 -0
        } else if (synth_init(new_synth_name) != 0) {
                pr_warn("failed to init synth %s\n", new_synth_name);
#2 lore raw
In reply to Tamara Diaconita
Quoted 16 lines · Tamara Diaconita

Delete comparison in 'if' structure to fix the checkpath.pl issue:
CHECK: Comparison to NULL could be written 'synth'.

Comparison to NULL is not necessary because 'if' structure tests if 'synth' is NULL anyway.

---
 drivers/staging/speakup/kobjects.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +0 -0
index ac6ed8b..0cd5384 100644

drivers/staging/speakup/kobjects.c static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, · line 394

Quoted 5 lines
drivers/staging/speakup/kobjects.c +1 -1
@@ -391,7 +391,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))) {

The parentheses around synth are also not needed.

julia

Quoted 13 lines
drivers/staging/speakup/kobjects.c +0 -1
 		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);
--

2.9.3

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170307092155.14802-1-diaconita.tamara%40gmail.com.
For more options, visit https://groups.google.com/d/optout.