Re: [PATCH] iscsi: Add break to while loop

2020-06-05 Thread The Lee-Man
On Thursday, June 4, 2020 at 5:10:49 AM UTC-7, Wu Bo wrote:
>
> From: liubo  
>
> Fix the potential risk of rc value being washed out by jumping out of the 
> loop 
>
> Signed-off-by: liubo  
> Reported-by: Zhiqiang Liu  
> --- 
>  utils/fwparam_ibft/fwparam_sysfs.c | 5 - 
>  1 file changed, 4 insertions(+), 1 deletion(-) 
>
> diff --git a/utils/fwparam_ibft/fwparam_sysfs.c 
> b/utils/fwparam_ibft/fwparam_sysfs.c 
> index a0cd1c7..87fd6d4 100644 
> --- a/utils/fwparam_ibft/fwparam_sysfs.c 
> +++ b/utils/fwparam_ibft/fwparam_sysfs.c 
> @@ -115,8 +115,11 @@ static int get_iface_from_device(char *id, struct 
> boot_context *context) 
>  break; 
>  } 
>   
> -if (sscanf(dent->d_name, "net:%s", 
> context->iface) != 1) 
> +if (sscanf(dent->d_name, "net:%s", 
> context->iface) != 1) { 
>  rc = EINVAL; 
> +break; 
> +} 
> + 
>  rc = 0; 
>  break; 
>  } else { 
> -- 
> 2.21.0.windows.1 
>
>
This looks fine to me. Any chance you could submit a pull request on 
GitHub? It saves me having to cut-and-paste, since I sadly do not have a 
good workflow setup for patches from the mailing list. 

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/a167b02a-53af-48ce-907a-5e43c67dd086o%40googlegroups.com.


Re: [EXT] [PATCH] iscsi: Add break to while loop

2020-06-05 Thread The Lee-Man
On Thursday, June 4, 2020 at 7:43:13 AM UTC-7, Uli wrote:
>
> >>> Wu Bo  schrieb am 04.06.2020 um 14:23 in Nachricht 
> <7784_1591272646_5ED8E4C6_7784_490_1_1591273415-689835-1-git-send-email-wubo40@h
>  
>
> awei.com>: 
> > From: liubo  
> > 
> > Fix the potential risk of rc value being washed out by jumping out of 
> the 
> > loop 
> > 
> > Signed-off-by: liubo  
> > Reported-by: Zhiqiang Liu  
> > --- 
> >  utils/fwparam_ibft/fwparam_sysfs.c | 5 - 
> >  1 file changed, 4 insertions(+), 1 deletion(-) 
> > 
> > diff --git a/utils/fwparam_ibft/fwparam_sysfs.c 
> > b/utils/fwparam_ibft/fwparam_sysfs.c 
> > index a0cd1c7..87fd6d4 100644 
> > --- a/utils/fwparam_ibft/fwparam_sysfs.c 
> > +++ b/utils/fwparam_ibft/fwparam_sysfs.c 
> > @@ -115,8 +115,11 @@ static int get_iface_from_device(char *id, struct 
> > boot_context *context) 
> >  break; 
> >  } 
> >   
> > -if (sscanf(dent->d_name, "net:%s", 
> context->iface) != 1) 
> > +if (sscanf(dent->d_name, "net:%s", 
> context->iface) != 1) { 
> >  rc = EINVAL; 
> > +break; 
> > +} 
> > + 
> >  rc = 0; 
> >  break; 
> >  } else { 
> > -- 
> > 2.21.0.windows.1 
>
> It seems to me the whole code could be more readable if the rc were preset 
> either to "success" (0) or "error" (something else), and if the "other" 
> result is needed just set the desired rc. Those multiple "break"s make the 
> code hard to read. 
>
>
>
Agreed that the code could be easier to read, but (1) it's working now, and 
(2) the suggested fix is inline with the current code style and format.

So I'm inclined to accept the patch. But I would also strongly consider a 
rewrite that makes it more readable, if you submitted such a patch.

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/3c3b346e-1d17-4e7a-ad38-5ef355146a45o%40googlegroups.com.


Antw: [EXT] [PATCH] iscsi: Add break to while loop

2020-06-04 Thread Ulrich Windl
>>> Wu Bo  schrieb am 04.06.2020 um 14:23 in Nachricht
<7784_1591272646_5ED8E4C6_7784_490_1_1591273415-689835-1-git-send-email-wubo40@h
awei.com>:
> From: liubo 
> 
> Fix the potential risk of rc value being washed out by jumping out of the 
> loop
> 
> Signed-off-by: liubo 
> Reported-by: Zhiqiang Liu 
> ---
>  utils/fwparam_ibft/fwparam_sysfs.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/fwparam_ibft/fwparam_sysfs.c 
> b/utils/fwparam_ibft/fwparam_sysfs.c
> index a0cd1c7..87fd6d4 100644
> --- a/utils/fwparam_ibft/fwparam_sysfs.c
> +++ b/utils/fwparam_ibft/fwparam_sysfs.c
> @@ -115,8 +115,11 @@ static int get_iface_from_device(char *id, struct 
> boot_context *context)
>   break;
>   }
>  
> - if (sscanf(dent->d_name, "net:%s", context->iface) != 1)
> + if (sscanf(dent->d_name, "net:%s", context->iface) != 
> 1) {
>   rc = EINVAL;
> + break;
> + }
> +
>   rc = 0;
>   break;
>   } else {
> -- 
> 2.21.0.windows.1

It seems to me the whole code could be more readable if the rc were preset 
either to "success" (0) or "error" (something else), and if the "other" result 
is needed just set the desired rc. Those multiple "break"s make the code hard 
to read.


> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "open-iscsi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to open-iscsi+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/open-iscsi/1591273415-689835-1-git-send-ema 
> il-wubo40%40huawei.com.




-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/5ED9087A02A100039500%40gwsmtp.uni-regensburg.de.


[PATCH] iscsi: Add break to while loop

2020-06-04 Thread Wu Bo
From: liubo 

Fix the potential risk of rc value being washed out by jumping out of the loop

Signed-off-by: liubo 
Reported-by: Zhiqiang Liu 
---
 utils/fwparam_ibft/fwparam_sysfs.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/utils/fwparam_ibft/fwparam_sysfs.c 
b/utils/fwparam_ibft/fwparam_sysfs.c
index a0cd1c7..87fd6d4 100644
--- a/utils/fwparam_ibft/fwparam_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -115,8 +115,11 @@ static int get_iface_from_device(char *id, struct 
boot_context *context)
break;
}
 
-   if (sscanf(dent->d_name, "net:%s", context->iface) != 1)
+   if (sscanf(dent->d_name, "net:%s", context->iface) != 
1) {
rc = EINVAL;
+   break;
+   }
+
rc = 0;
break;
} else {
-- 
2.21.0.windows.1

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/1591273415-689835-1-git-send-email-wubo40%40huawei.com.