diff mbox series

kernel: capability: Remove unnecessary ‘0’ values from ret

Message ID 20231228030854.11689-1-zeming@nfschina.com (mailing list archive)
State Rejected
Headers show
Series kernel: capability: Remove unnecessary ‘0’ values from ret | expand

Commit Message

Li zeming Dec. 28, 2023, 3:08 a.m. UTC
The ret variable is assigned when it does not need to be defined, as it
has already been assigned before use.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 kernel/capability.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Serge E. Hallyn Jan. 10, 2024, 3:47 p.m. UTC | #1
On Thu, Dec 28, 2023 at 11:08:54AM +0800, Li zeming wrote:
> The ret variable is assigned when it does not need to be defined, as it
> has already been assigned before use.
> 
> Signed-off-by: Li zeming <zeming@nfschina.com>

This is true, so the patch would fine now.  But it has not always been
the case, and a future patch could add code at the start which makes it
no longer true.  While I'd hope we would easily catch that, I'm just not
sure it's worth it.  In fact I'm curious - does the compiler recognize
this situation and optimize the = 0 away?

> ---
>  kernel/capability.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/capability.c b/kernel/capability.c
> index dac4df77e376e..ed8a983e21da4 100644
> --- a/kernel/capability.c
> +++ b/kernel/capability.c
> @@ -140,7 +140,7 @@ static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp,
>   */
>  SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
>  {
> -	int ret = 0;
> +	int ret;
>  	pid_t pid;
>  	unsigned tocopy;
>  	kernel_cap_t pE, pI, pP;
> -- 
> 2.18.2
diff mbox series

Patch

diff --git a/kernel/capability.c b/kernel/capability.c
index dac4df77e376e..ed8a983e21da4 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -140,7 +140,7 @@  static inline int cap_get_target_pid(pid_t pid, kernel_cap_t *pEp,
  */
 SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
 {
-	int ret = 0;
+	int ret;
 	pid_t pid;
 	unsigned tocopy;
 	kernel_cap_t pE, pI, pP;