* [PATCH] loongarch: kgdb: remove unnecessary init variable @ 2025-05-30 7:09 Li Jun 2025-06-03 1:20 ` Yanteng Si 0 siblings, 1 reply; 6+ messages in thread From: Li Jun @ 2025-05-30 7:09 UTC (permalink / raw) To: chenhuacai, kernel, lijun01, loongarch the get_step_address(regs, &addr) should assign a value to 'error' before it is read.so the var don't need init to 0. Signed-off-by: Li Jun <lijun01@kylinos.cn> --- arch/loongarch/kernel/kgdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c index 7be5b4c0c900..df3c7a5565e9 100644 --- a/arch/loongarch/kernel/kgdb.c +++ b/arch/loongarch/kernel/kgdb.c @@ -379,7 +379,7 @@ static int get_step_address(struct pt_regs *regs, unsigned long *next_addr) static int do_single_step(struct pt_regs *regs) { - int error = 0; + int error; unsigned long addr = 0; /* Determine where the target instruction will send us to */ error = get_step_address(regs, &addr); -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] loongarch: kgdb: remove unnecessary init variable 2025-05-30 7:09 [PATCH] loongarch: kgdb: remove unnecessary init variable Li Jun @ 2025-06-03 1:20 ` Yanteng Si 2025-06-03 2:55 ` lijun 2025-06-03 3:30 ` lijun 0 siblings, 2 replies; 6+ messages in thread From: Yanteng Si @ 2025-06-03 1:20 UTC (permalink / raw) To: Li Jun, chenhuacai, kernel, loongarch 在 5/30/25 3:09 PM, Li Jun 写道: > the get_step_address(regs, &addr) should assign a value > to 'error' before it is read.so the var don't need init > to 0. So, is it wrong to initialize it to 0 now? Thanks, Yanteng > > Signed-off-by: Li Jun <lijun01@kylinos.cn> > --- > arch/loongarch/kernel/kgdb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c > index 7be5b4c0c900..df3c7a5565e9 100644 > --- a/arch/loongarch/kernel/kgdb.c > +++ b/arch/loongarch/kernel/kgdb.c > @@ -379,7 +379,7 @@ static int get_step_address(struct pt_regs *regs, unsigned long *next_addr) > > static int do_single_step(struct pt_regs *regs) > { > - int error = 0; > + int error; > unsigned long addr = 0; /* Determine where the target instruction will send us to */ > > error = get_step_address(regs, &addr); ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] loongarch: kgdb: remove unnecessary init variable 2025-06-03 1:20 ` Yanteng Si @ 2025-06-03 2:55 ` lijun 2025-06-03 3:30 ` lijun 1 sibling, 0 replies; 6+ messages in thread From: lijun @ 2025-06-03 2:55 UTC (permalink / raw) To: Yanteng Si, chenhuacai, kernel, loongarch; +Cc: lijun01 it is not a wrong, just look clean. -------------------------- > 在 5/30/25 3:09 PM, Li Jun 写道: > > the get_step_address(regs, &addr) should assign a value > > to 'error' before it is read.so the var don't need init > > to 0. > > So, is it wrong to initialize it to 0 now? > > > Thanks, > Yanteng > > Signed-off-by: Li Jun < > > lijun01@kylinos.cn > > > > > --- > > arch/loongarch/kernel/kgdb.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/loongarch/kernel/kgdb.c > > b/arch/loongarch/kernel/kgdb.c > > index 7be5b4c0c900..df3c7a5565e9 100644 > > --- a/arch/loongarch/kernel/kgdb.c > > +++ b/arch/loongarch/kernel/kgdb.c > > @@ -379,7 +379,7 @@ static int get_step_address(struct pt_regs > > *regs, unsigned long *next_addr) > > > > static int do_single_step(struct pt_regs *regs) > > { > > - int error = 0; > > + int error; > > unsigned long addr = 0; /* Determine where the target > > instruction will send us to */ > > > > error = get_step_address(regs, &addr); ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] loongarch: kgdb: remove unnecessary init variable 2025-06-03 1:20 ` Yanteng Si 2025-06-03 2:55 ` lijun @ 2025-06-03 3:30 ` lijun 2025-06-04 1:40 ` Yanteng Si 1 sibling, 1 reply; 6+ messages in thread From: lijun @ 2025-06-03 3:30 UTC (permalink / raw) To: Yanteng Si, chenhuacai, kernel, loongarch; +Cc: lijun01 it is not a wrong, just look clean. -------------------------- > 在 5/30/25 3:09 PM, Li Jun 写道: > > the get_step_address(regs, &addr) should assign a value > > to 'error' before it is read.so the var don't need init > > to 0. > > So, is it wrong to initialize it to 0 now? > > > Thanks, > Yanteng > > Signed-off-by: Li Jun < > > lijun01@kylinos.cn > > > > --- > > arch/loongarch/kernel/kgdb.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/loongarch/kernel/kgdb.c > > b/arch/loongarch/kernel/kgdb.c > > index 7be5b4c0c900..df3c7a5565e9 100644 > > --- a/arch/loongarch/kernel/kgdb.c > > +++ b/arch/loongarch/kernel/kgdb.c > > @@ -379,7 +379,7 @@ static int get_step_address(struct pt_regs > > *regs, unsigned long *next_addr) > > > > static int do_single_step(struct pt_regs *regs) > > { > > - int error = 0; > > + int error; > > unsigned long addr = 0; /* Determine where the target > > instruction will send us to */ > > > > error = get_step_address(regs, &addr); ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] loongarch: kgdb: remove unnecessary init variable 2025-06-03 3:30 ` lijun @ 2025-06-04 1:40 ` Yanteng Si 2025-06-04 2:57 ` Re:[PATCH] " lijun 0 siblings, 1 reply; 6+ messages in thread From: Yanteng Si @ 2025-06-04 1:40 UTC (permalink / raw) To: lijun, chenhuacai, kernel, loongarch 在 6/3/25 11:30 AM, lijun 写道: > it is not a wrong, just look clean. Alright, as you said, just for the clean. First, you deleted one line and added another, so the number of code lines remains unchanged, and the original line of code wasn't complicated to begin with. Second, your patch only deletes two characters, and I don't think this will significantly improve the code's readability. Finally, creating a patch for this consumes the limited energy of reviewers and maintainers (many of whom are working outside of regular working hours), and a lot of CI infrastructure will consume electricity to test your patch. It's not that I'm against your patch; I just want to know if it's worth it? BTW, We don't accept the top reply. Thanks, Yanteng > > > > -------------------------- >> 在 5/30/25 3:09 PM, Li Jun 写道: >>> the get_step_address(regs, &addr) should assign a value >>> to 'error' before it is read.so the var don't need init >>> to 0. >> >> So, is it wrong to initialize it to 0 now? >> >> >> Thanks, >> Yanteng >>> Signed-off-by: Li Jun < >>> lijun01@kylinos.cn >>> >>> --- >>> arch/loongarch/kernel/kgdb.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/arch/loongarch/kernel/kgdb.c >>> b/arch/loongarch/kernel/kgdb.c >>> index 7be5b4c0c900..df3c7a5565e9 100644 >>> --- a/arch/loongarch/kernel/kgdb.c >>> +++ b/arch/loongarch/kernel/kgdb.c >>> @@ -379,7 +379,7 @@ static int get_step_address(struct pt_regs >>> *regs, unsigned long *next_addr) >>> >>> static int do_single_step(struct pt_regs *regs) >>> { >>> - int error = 0; >>> + int error; >>> unsigned long addr = 0; /* Determine where the target >>> instruction will send us to */ >>> >>> error = get_step_address(regs, &addr); > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re:[PATCH] loongarch: kgdb: remove unnecessary init variable 2025-06-04 1:40 ` Yanteng Si @ 2025-06-04 2:57 ` lijun 0 siblings, 0 replies; 6+ messages in thread From: lijun @ 2025-06-04 2:57 UTC (permalink / raw) To: Yanteng Si, chenhuacai, kernel, loongarch; +Cc: lijun01 The compiler generates initialization instructions, which consume additional CPU cycles -------------------------------------- Alright, as you said, just for the clean. First, you deleted one line and added another, so the number of code lines remains unchanged, and the original line of code wasn't complicated to begin with. Second, your patch only deletes two characters, and I don't think this will significantly improve the code's readability. Finally, creating a patch for this consumes the limited energy of reviewers and maintainers (many of whom are working outside of regular working hours), and a lot of CI infrastructure will consume electricity to test your patch. It's not that I'm against your patch; I just want to know if it's worth it? BTW, We don't accept the top reply. Thanks, Yanteng ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-04 2:57 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-05-30 7:09 [PATCH] loongarch: kgdb: remove unnecessary init variable Li Jun 2025-06-03 1:20 ` Yanteng Si 2025-06-03 2:55 ` lijun 2025-06-03 3:30 ` lijun 2025-06-04 1:40 ` Yanteng Si 2025-06-04 2:57 ` Re:[PATCH] " lijun
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).