Skip to contentSkip to conversation

kexec: Remove unused code in kimage_load_cma_segment()

PATCH RESEND In review Andy Shevchenko 2 participants 6 messages Sep 16, 2025 – Oct 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 kexec: Remove unused code in kimage_load_cma_segment()

clang is not happy about set but unused variable:

kernel/kexec_core.c:745:16: error: variable 'maddr' set but not used [-Werror,-Wunused-but-set-variable]
745 | unsigned long maddr;
| ^
1 error generated.

Fix the compilation breakage (make W=1 build) by removing unused variable.

As Nathan noted, GCC 16 produces the similar warning;

Fixes f4fecb50d6e1 ("kexec_core: remove superfluous page offset handling in segment loading")

---

v2: fixed Fixes (Nathan), added a note about GCC (Nathan), added tag (Nathan)

 kernel/kexec_core.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/kexec_core.c +0 -3
index 5357ed39e9d1..32722926bc7e 100644
@@ -742,7 +742,6 @@ static int kimage_load_cma_segment(struct kimage *image, int idx)
 	struct kexec_segment *segment = &image->segment[idx];
 	struct page *cma = image->segment_cma[idx];
 	char *ptr = page_address(cma);
-	unsigned long maddr;
 	size_t ubytes, mbytes;
 	int result = 0;
 	unsigned char __user *buf = NULL;
@@ -754,7 +753,6 @@ static int kimage_load_cma_segment(struct kimage *image, int idx)
 		buf = segment->buf;
 	ubytes = segment->bufsz;
 	mbytes = segment->memsz;
-	maddr = segment->mem;
 
 	/* Then copy from source buffer to the CMA one */
 	while (mbytes) {
@@ -782,7 +780,6 @@ static int kimage_load_cma_segment(struct kimage *image, int idx)
 		}
 
 		ptr    += mchunk;
-		maddr  += mchunk;
 		mbytes -= mchunk;
 
 		cond_resched();
Signature · 1 line
2.50.1
#1 lore raw
Quoted 7 lines · Andy Shevchenko

clang is not happy about set but unused variable:

kernel/kexec_core.c:745:16: error: variable 'maddr' set but not used [-Werror,-Wunused-but-set-variable]
745 | unsigned long maddr;
| ^
1 error generated.

Quoted 5 lines

Fix the compilation breakage (make W=1 build) by removing unused variable.

As Nathan noted, GCC 16 produces the similar warning;

Fixes f4fecb50d6e1 ("kexec_core: remove superfluous page offset handling in segment loading")

FYI the commit this patch is fixing (i.e. f4fecb50d6e1) is going to need a second revision as well (I haven't submitted it yet, still working on it), this means that your "Fixes:" tag will need to be changed again, requiring a 3rd revision.

I am not sure what is the proper way forward here. Should I:
- Send my v2, without fixing the unused variable and then you send your v3 with the updated "Fixes:" tag pointing to my v2.
- OR fixing the unused variable in my v2 (i.e. "absorb" this patch in my v2).
In the latter case, I am not sure how I am supposed to credit the work in this case? Do I need to add another "Signed-off-by: Andy Shevchenko" besides mine?

I'm still learning the ropes on how to contribute through the mailing list so I would be grateful if you could share your input on what's the proper way forward here.

Best,
Justinien

Quoted 40 lines

---

v2: fixed Fixes (Nathan), added a note about GCC (Nathan), added tag (Nathan)

 kernel/kexec_core.c | 3 ---
 1 file changed, 3 deletions(-)
kernel/kexec_core.c +0 -3
index 5357ed39e9d1..32722926bc7e 100644
@@ -742,7 +742,6 @@ static int kimage_load_cma_segment(struct kimage *image, int idx)
 	struct kexec_segment *segment = &image->segment[idx];
 	struct page *cma = image->segment_cma[idx];
 	char *ptr = page_address(cma);
-	unsigned long maddr;
 	size_t ubytes, mbytes;
 	int result = 0;
 	unsigned char __user *buf = NULL;
@@ -754,7 +753,6 @@ static int kimage_load_cma_segment(struct kimage *image, int idx)
 		buf = segment->buf;
 	ubytes = segment->bufsz;
 	mbytes = segment->memsz;
-	maddr = segment->mem;
 
 	/* Then copy from source buffer to the CMA one */
 	while (mbytes) {
@@ -782,7 +780,6 @@ static int kimage_load_cma_segment(struct kimage *image, int idx)
 		}
 
 		ptr    += mchunk;
-		maddr  += mchunk;
 		mbytes -= mchunk;
 
 		cond_resched();
Signature · 1 line
2.50.1
#2 lore raw
Quoted 18 lines · Justinien Bouron
Quoted 7 lines · Andy Shevchenko

clang is not happy about set but unused variable:

kernel/kexec_core.c:745:16: error: variable 'maddr' set but not used [-Werror,-Wunused-but-set-variable]
745 | unsigned long maddr;
| ^
1 error generated.

Quoted 5 lines

Fix the compilation breakage (make W=1 build) by removing unused variable.

As Nathan noted, GCC 16 produces the similar warning;

Fixes f4fecb50d6e1 ("kexec_core: remove superfluous page offset handling in segment loading")

FYI the commit this patch is fixing (i.e. f4fecb50d6e1) is going to need a second revision as well (I haven't submitted it yet, still working on it), this means that your "Fixes:" tag will need to be changed again, requiring a 3rd revision.

Quoted 5 lines

I am not sure what is the proper way forward here. Should I:
- Send my v2, without fixing the unused variable and then you send your v3 with the updated "Fixes:" tag pointing to my v2.
- OR fixing the unused variable in my v2 (i.e. "absorb" this patch in my v2).

Second is the best (integrate this fix into yours v2).

Quoted 2 lines

In the latter case, I am not sure how I am supposed to credit the work in this case? Do I need to add another "Signed-off-by: Andy Shevchenko" besides mine?

Just in the comment block (after the cutter '---' line and before the diff) in a free words. No need for any special tags for this in such a case.

Quoted 3 lines

I'm still learning the ropes on how to contribute through the mailing list so I would be grateful if you could share your input on what's the proper way forward here.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 25 lines · Andy Shevchenko
Quoted 18 lines · Justinien Bouron
Quoted 7 lines · Andy Shevchenko

clang is not happy about set but unused variable:

kernel/kexec_core.c:745:16: error: variable 'maddr' set but not used [-Werror,-Wunused-but-set-variable]
745 | unsigned long maddr;
| ^
1 error generated.

Quoted 5 lines

Fix the compilation breakage (make W=1 build) by removing unused variable.

As Nathan noted, GCC 16 produces the similar warning;

Fixes f4fecb50d6e1 ("kexec_core: remove superfluous page offset handling in segment loading")

FYI the commit this patch is fixing (i.e. f4fecb50d6e1) is going to need a second revision as well (I haven't submitted it yet, still working on it), this means that your "Fixes:" tag will need to be changed again, requiring a 3rd revision.

Quoted 5 lines

I am not sure what is the proper way forward here. Should I:
- Send my v2, without fixing the unused variable and then you send your v3 with the updated "Fixes:" tag pointing to my v2.
- OR fixing the unused variable in my v2 (i.e. "absorb" this patch in my v2).

Quoted 11 lines

Second is the best (integrate this fix into yours v2).

Quoted 2 lines

In the latter case, I am not sure how I am supposed to credit the work in this case? Do I need to add another "Signed-off-by: Andy Shevchenko" besides mine?

Just in the comment block (after the cutter '---' line and before the diff) in a free words. No need for any special tags for this in such a case.

Quoted 3 lines

I'm still learning the ropes on how to contribute through the mailing list so I would be grateful if you could share your input on what's the proper way forward here.

Any news, folks, please? The bug is still in Linux Next and prevents me from building my stuff cleanly.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 34 lines · Andy Shevchenko
Quoted 33 lines · Andy Shevchenko
Quoted 18 lines · Justinien Bouron
Quoted 7 lines · Andy Shevchenko

clang is not happy about set but unused variable:

kernel/kexec_core.c:745:16: error: variable 'maddr' set but not used [-Werror,-Wunused-but-set-variable]
745 | unsigned long maddr;
| ^
1 error generated.

Quoted 5 lines

Fix the compilation breakage (make W=1 build) by removing unused variable.

As Nathan noted, GCC 16 produces the similar warning;

Fixes f4fecb50d6e1 ("kexec_core: remove superfluous page offset handling in segment loading")

FYI the commit this patch is fixing (i.e. f4fecb50d6e1) is going to need a second revision as well (I haven't submitted it yet, still working on it), this means that your "Fixes:" tag will need to be changed again, requiring a 3rd revision.

Quoted 5 lines

I am not sure what is the proper way forward here. Should I:
- Send my v2, without fixing the unused variable and then you send your v3 with the updated "Fixes:" tag pointing to my v2.
- OR fixing the unused variable in my v2 (i.e. "absorb" this patch in my v2).

Second is the best (integrate this fix into yours v2).

Quoted 2 lines

In the latter case, I am not sure how I am supposed to credit the work in this case? Do I need to add another "Signed-off-by: Andy Shevchenko" besides mine?

Just in the comment block (after the cutter '---' line and before the diff) in a free words. No need for any special tags for this in such a case.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

I'm still learning the ropes on how to contribute through the mailing list so I would be grateful if you could share your input on what's the proper way forward here.

Any news, folks, please? The bug is still in Linux Next and prevents me from building my stuff cleanly.

I am working on sending the V3 as we speak, sorry for the delay.

Best,
Justinien Bouron

Quoted 6 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Andy Shevchenko
Quoted 34 lines · Andy Shevchenko
Quoted 33 lines · Andy Shevchenko
Quoted 18 lines · Justinien Bouron
Quoted 7 lines · Andy Shevchenko

clang is not happy about set but unused variable:

kernel/kexec_core.c:745:16: error: variable 'maddr' set but not used [-Werror,-Wunused-but-set-variable]
745 | unsigned long maddr;
| ^
1 error generated.

Quoted 5 lines

Fix the compilation breakage (make W=1 build) by removing unused variable.

As Nathan noted, GCC 16 produces the similar warning;

Fixes f4fecb50d6e1 ("kexec_core: remove superfluous page offset handling in segment loading")

FYI the commit this patch is fixing (i.e. f4fecb50d6e1) is going to need a second revision as well (I haven't submitted it yet, still working on it), this means that your "Fixes:" tag will need to be changed again, requiring a 3rd revision.

Quoted 5 lines

I am not sure what is the proper way forward here. Should I:
- Send my v2, without fixing the unused variable and then you send your v3 with the updated "Fixes:" tag pointing to my v2.
- OR fixing the unused variable in my v2 (i.e. "absorb" this patch in my v2).

Second is the best (integrate this fix into yours v2).

Quoted 2 lines

In the latter case, I am not sure how I am supposed to credit the work in this case? Do I need to add another "Signed-off-by: Andy Shevchenko" besides mine?

Just in the comment block (after the cutter '---' line and before the diff) in a free words. No need for any special tags for this in such a case.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

I'm still learning the ropes on how to contribute through the mailing list so I would be grateful if you could share your input on what's the proper way forward here.

Any news, folks, please? The bug is still in Linux Next and prevents me from building my stuff cleanly.

V3 is up: https://lore.kernel.org/lkml/[email protected]/

Best,
Justinien Bouron

Quoted 6 lines
Signature · 3 lines
-- 
With Best Regards,
Andy Shevchenko