Skip to contentSkip to conversation

mm/hugetlb.c: remove dead store in demote_size_show()

PATCH In review Nghia Le 3 participants 5 messages Oct 3, 2021 – Oct 4, 2021

Subsystems (3)
lore
Share & tools
lore

Nghia Le

author
#0 lore raw

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

The command "make clang-analyzer" detected a dead store.

Remove demote_size and corresponding assignment in function demote_size_show() to fix dead store, as 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

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

Quoted 10 lines · Nghia Le

{

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);

I'd suggest this function would look better written as:

	int nid;
	struct hstate *h = kobj_to_hstate(kobj, &nid);
	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;

	return sysfs_emit(buf, "%lukB\n", demote_size);
#2 lore raw
Quoted 14 lines · Matthew Wilcox

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

Quoted 10 lines · Nghia Le

{

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);

I'd suggest this function would look better written as:

Quoted 6 lines
	int nid;
	struct hstate *h = kobj_to_hstate(kobj, &nid);
	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;

	return sysfs_emit(buf, "%lukB\n", demote_size);

Thank you Nghia Le for spotting this, and thank you Matthew for the suggestion.

This is still just in Andrew's tree and subject to modification before the next merge window. I am still expecting additional comments on the series.

If another version of the series is needed, I will include Matthew's
suggestion. If not, I will ask Andrew how he would prefer to fold in
the changes.

Signature · 1 line
Mike Kravetz
author
#3 lore raw
Quoted 15 lines · Mike Kravetz
Quoted 14 lines · Matthew Wilcox

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

Quoted 10 lines · Nghia Le

{

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);

I'd suggest this function would look better written as:

Quoted 6 lines
Quoted 6 lines
	int nid;
	struct hstate *h = kobj_to_hstate(kobj, &nid);
	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;

	return sysfs_emit(buf, "%lukB\n", demote_size);

Thanks Matthew for the clean code.

Quoted 4 lines

Thank you Nghia Le for spotting this, and thank you Matthew for the suggestion.

Quoted 9 lines

This is still just in Andrew's tree and subject to modification before the next merge window. I am still expecting additional comments on the series.

If another version of the series is needed, I will include Matthew's
suggestion. If not, I will ask Andrew how he would prefer to fold in
the changes.

Signature · 1 line
Mike Kravetz

Thanks Mike, so we will wait further comments from Andrew and others.

#4 lore raw
Quoted 31 lines · Nghia Le
Quoted 15 lines · Mike Kravetz
Quoted 14 lines · Matthew Wilcox

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

Quoted 10 lines · Nghia Le

{

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);

I'd suggest this function would look better written as:

Quoted 6 lines
Quoted 6 lines
	int nid;
	struct hstate *h = kobj_to_hstate(kobj, &nid);
	unsigned long demote_size = (PAGE_SIZE << h->demote_order) / SZ_1K;

	return sysfs_emit(buf, "%lukB\n", demote_size);

Thanks Matthew for the clean code.

Quoted 8 lines

Thank you Nghia Le for spotting this, and thank you Matthew for the suggestion.

This is still just in Andrew's tree and subject to modification before the next merge window. I am still expecting additional comments on the series.

Quoted 6 lines
Quoted 5 lines

If another version of the series is needed, I will include Matthew's
suggestion. If not, I will ask Andrew how he would prefer to fold in
the changes.

Signature · 1 line
Mike Kravetz

Thanks Mike, so we will wait further comments from Andrew and others.

Yes, I received suggestions for other improvements to the patch which contains this code. I will be putting together another version of the series with at least these changes.

Thanks,

Signature · 1 line
Mike Kravetz