Skip to contentSkip to conversation

mm/hugetlb.c: remove deadstore in demote_size_show()

PATCH Superseded Nghia Le 2 participants 3 messages Oct 1, 2021 – Oct 2, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nghia Le

author
#0 lore raw

PATCH 1/1 mm/hugetlb.c: remove deadstore in demote_size_show()

Deadstore was detected by CodeCheck tool (ELISA group)

Removed demote_size and relevant assignment in function demote_size_show() to fix deadstore issue of which stored value to demote_size is never read

---
 mm/hugetlb.c | 2 --
 1 file changed, 2 deletions(-)
mm/hugetlb.c +0 -2
index 993efa70bce4..ef00e6ad0f6a 100644
@@ -3706,11 +3706,9 @@ static ssize_t demote_size_show(struct kobject *kobj,
 					struct kobj_attribute *attr, char *buf)
 {
 	struct hstate *h;
-	unsigned long demote_size;
 	int nid;
 
 	h = kobj_to_hstate(kobj, &nid);
-	demote_size = h->demote_order;
 
 	return sysfs_emit(buf, "%lukB\n",
 			(unsigned long)(PAGE_SIZE << h->demote_order) / SZ_1K);
Signature · 1 line
2.25.1
#1 lore raw

Just some minor improvements for the language:

Quoted 2 lines · Nghia Le

Deadstore was detected by CodeCheck tool (ELISA group)

Hints:
- Use active instead of passive tense
- It is detected by "make clang-analyzer". The CodeChecker tool is
just the webUI frontend.
- Dead store is written as two words (with a space between dead and store).

So, make it:
The command "make clang-analyzer" detected a dead store.

Quoted 4 lines

Removed demote_size and relevant assignment in function demote_size_show() to fix deadstore issue of which stored value to demote_size is never read

Hints:
- Use imperative form.
- ... and just some better English grammar.

So make it:
Remove demote_size and corresponding assignment in function demote_size_show() to fix dead store, as demote_size is never read.

Also change deadstore to dead store in subject.

Other than that, it looks good to me.

Send a PATCH v2 here. Then, we check again and you can send the patch out to the maintainers.

Lukas

Quoted 24 lines
---
 mm/hugetlb.c | 2 --
 1 file changed, 2 deletions(-)
mm/hugetlb.c +0 -3
index 993efa70bce4..ef00e6ad0f6a 100644
@@ -3706,11 +3706,9 @@ static ssize_t demote_size_show(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
        struct hstate *h;
-       unsigned long demote_size;
        int nid;
 
        h = kobj_to_hstate(kobj, &nid);
-       demote_size = h->demote_order;
 
        return sysfs_emit(buf, "%lukB\n",
                        (unsigned long)(PAGE_SIZE << h->demote_order) / SZ_1K);
--

2.25.1

author
#2 lore raw

Dear Lukas,
Thank you for detailed comments as well as your help. Patch v2 is ready for next review.
Best regards,
Nghia Le

Quoted 68 lines · Lukas Bulwahn

Just some minor improvements for the language:

Quoted 2 lines · Nghia Le

Deadstore was detected by CodeCheck tool (ELISA group)

Hints:
- Use active instead of passive tense
- It is detected by "make clang-analyzer". The CodeChecker tool is
just the webUI frontend.
- Dead store is written as two words (with a space between dead and
store).

So, make it:
The command "make clang-analyzer" detected a dead store.

Quoted 2 lines

Removed demote_size and relevant assignment in function

demote_size_show()

Quoted 2 lines

to fix deadstore issue of which stored value to demote_size is never read

Hints:
- Use imperative form.
- ... and just some better English grammar.

So make it:
Remove demote_size and corresponding assignment in function demote_size_show()
to fix dead store, as demote_size is never read.

Also change deadstore to dead store in subject.

Other than that, it looks good to me.

Send a PATCH v2 here. Then, we check again and you can send the patch out to the maintainers.

Lukas

mm/hugetlb.c static ssize_t demote_size_show(struct kobject

Quoted 10 lines
---
 mm/hugetlb.c | 2 --
 1 file changed, 2 deletions(-)
mm/hugetlb.c +0 -0
index 993efa70bce4..ef00e6ad0f6a 100644
@@ -3706,11 +3706,9 @@ static ssize_t demote_size_show(struct kobject

*kobj,

mm/hugetlb.c static ssize_t demote_size_show(struct kobject · line 3706

Quoted 1 line
mm/hugetlb.c +0 -0
                                        struct kobj_attribute *attr,

char *buf)

mm/hugetlb.c static ssize_t demote_size_show(struct kobject *kobj,

Quoted 10 lines
mm/hugetlb.c +0 -2
 {
        struct hstate *h;
-       unsigned long demote_size;
        int nid;
 
        h = kobj_to_hstate(kobj, &nid);
-       demote_size = h->demote_order;
 
        return sysfs_emit(buf, "%lukB\n",
                        (unsigned long)(PAGE_SIZE << h->demote_order) /

SZ_1K);

Quoted 3 lines

--
2.25.1