Re: [PATCH 1/2] iscsiadm: Correct the comparison for invalid hostno in host mode

2013-05-28 Thread Mike Christie
On 04/05/2013 06:34 AM, vikas.chaudh...@qlogic.com wrote:
 From: Adheer Chandravanshi adheer.chandravan...@qlogic.com
 
 Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
 Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
 ---
  usr/iscsiadm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
 index 5a18522..f87f48c 100644
 --- a/usr/iscsiadm.c
 +++ b/usr/iscsiadm.c
 @@ -3016,7 +3016,7 @@ main(int argc, char **argv)
   if (sub_mode != -1) {
   switch (sub_mode) {
   case MODE_CHAP:
 - if (!op || !host_no) {
 + if (!op || (host_no == 0x)) {
   log_error(CHAP mode requires host 
   no and valid operation);
   rc = ISCSI_ERR_INVAL;
 @@ -3026,7 +3026,7 @@ main(int argc, char **argv)
  value);
   break;
   case MODE_FLASHNODE:
 - if (!host_no) {
 + if (host_no == 0x) {
   log_error(FLASHNODE mode requires host 
 no);
   rc = ISCSI_ERR_INVAL;
   break;
 

I merged the attached instead. It uses a define instead.

-- 
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 post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


diff --git a/usr/host.h b/usr/host.h
index 894ab91..bb65a77 100644
--- a/usr/host.h
+++ b/usr/host.h
@@ -5,6 +5,8 @@
 #include types.h
 #include config.h
 
+#define MAX_HOST_NO 0x
+
 #define MAX_CHAP_BUF_SZ 4096
 #define REQ_CHAP_BUF_SZ (MAX_CHAP_BUF_SZ + sizeof(struct iscsi_uevent))
 
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 84d5a27..7b257b9 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -3019,7 +3019,7 @@ main(int argc, char **argv)
if (sub_mode != -1) {
switch (sub_mode) {
case MODE_CHAP:
-   if (!op || !host_no) {
+   if (!op || (host_no == MAX_HOST_NO)) {
log_error(CHAP mode requires host 
no and valid operation);
rc = ISCSI_ERR_INVAL;
@@ -3029,7 +3029,7 @@ main(int argc, char **argv)
   value);
break;
case MODE_FLASHNODE:
-   if (!host_no) {
+   if (host_no == MAX_HOST_NO) {
log_error(FLASHNODE mode requires host 
no);
rc = ISCSI_ERR_INVAL;
break;


Re: [PATCH 1/2] iscsiadm: Correct the comparison for invalid hostno in host mode

2013-05-28 Thread Mike Christie
On 05/28/2013 03:27 AM, Mike Christie wrote:
 On 04/05/2013 06:34 AM, vikas.chaudh...@qlogic.com wrote:
 From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

 Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
 Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
 ---
  usr/iscsiadm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
 index 5a18522..f87f48c 100644
 --- a/usr/iscsiadm.c
 +++ b/usr/iscsiadm.c
 @@ -3016,7 +3016,7 @@ main(int argc, char **argv)
  if (sub_mode != -1) {
  switch (sub_mode) {
  case MODE_CHAP:
 -if (!op || !host_no) {
 +if (!op || (host_no == 0x)) {
  log_error(CHAP mode requires host 
  no and valid operation);
  rc = ISCSI_ERR_INVAL;
 @@ -3026,7 +3026,7 @@ main(int argc, char **argv)
 value);
  break;
  case MODE_FLASHNODE:
 -if (!host_no) {
 +if (host_no == 0x) {
  log_error(FLASHNODE mode requires host 
 no);
  rc = ISCSI_ERR_INVAL;
  break;

 
 I merged the attached instead. It uses a define instead.
 

Actually, this is wrong. I guess the host no in the kernel is now a
unsigned int, so 0x is a valid host no. I think we have to make
the host no a unin64_t?

Same for flashnode_idx. That should be fixed and the hard coding of the
max should be replaced with a define instead of hard coding 0x
in places like exec_flashnode_op.

-- 
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 post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Antw: Re: [PATCH 1/2] iscsiadm: Correct the comparison for invalid hostno in host mode

2013-05-28 Thread Ulrich Windl
 Mike Christie micha...@cs.wisc.edu schrieb am 28.05.2013 um 10:34 in
Nachricht 51a46c13.3030...@cs.wisc.edu:
 On 05/28/2013 03:27 AM, Mike Christie wrote:
 On 04/05/2013 06:34 AM, vikas.chaudh...@qlogic.com wrote:
 From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

 Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
 Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
 ---
  usr/iscsiadm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
 index 5a18522..f87f48c 100644
 --- a/usr/iscsiadm.c
 +++ b/usr/iscsiadm.c
 @@ -3016,7 +3016,7 @@ main(int argc, char **argv)
 if (sub_mode != -1) {
 switch (sub_mode) {
 case MODE_CHAP:
 -   if (!op || !host_no) {
 +   if (!op || (host_no == 0x)) {
 log_error(CHAP mode requires host 
 no and valid operation);
 rc = ISCSI_ERR_INVAL;
 @@ -3026,7 +3026,7 @@ main(int argc, char **argv)
value);
 break;
 case MODE_FLASHNODE:
 -   if (!host_no) {
 +   if (host_no == 0x) {
 log_error(FLASHNODE mode requires host 
 no);
 rc = ISCSI_ERR_INVAL;
 break;

 
 I merged the attached instead. It uses a define instead.
 
 
 Actually, this is wrong. I guess the host no in the kernel is now a
 unsigned int, so 0x is a valid host no. I think we have to make
 the host no a unin64_t?

Whatever it is or will be: It seems to be a good reason for a macro like 
#define valid_host_no(h) ((h) != whatever)
I away wonder whether 0x is (unsigned) -1. I would avoid concrete 
bits as much as possible...

 
 Same for flashnode_idx. That should be fixed and the hard coding of the
 max should be replaced with a define instead of hard coding 0x
 in places like exec_flashnode_op.
 
 -- 
 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 post to this group, send email to open-iscsi@googlegroups.com.
 Visit this group at http://groups.google.com/group/open-iscsi?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.



-- 
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 post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Antw: Re: [PATCH 1/2] iscsiadm: Correct the comparison for invalid hostno in host mode

2013-05-28 Thread Ulrich Windl
 I wrote a moment ago:
[...]
 I away wonder whether 0x is (unsigned) -1. I would avoid concrete 

away was meant to read always: Isn't it interesting how a tired mind works? 
;-) Sorry for the bad typing!

 bits as much as possible...
[...]


-- 
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 post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[PATCH 1/2] iscsiadm: Correct the comparison for invalid hostno in host mode

2013-04-05 Thread vikas . chaudhary
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 usr/iscsiadm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 5a18522..f87f48c 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -3016,7 +3016,7 @@ main(int argc, char **argv)
if (sub_mode != -1) {
switch (sub_mode) {
case MODE_CHAP:
-   if (!op || !host_no) {
+   if (!op || (host_no == 0x)) {
log_error(CHAP mode requires host 
no and valid operation);
rc = ISCSI_ERR_INVAL;
@@ -3026,7 +3026,7 @@ main(int argc, char **argv)
   value);
break;
case MODE_FLASHNODE:
-   if (!host_no) {
+   if (host_no == 0x) {
log_error(FLASHNODE mode requires host 
no);
rc = ISCSI_ERR_INVAL;
break;
-- 
1.8.2.GIT

-- 
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 post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.