Skip to contentSkip to conversation

Followup corrections for kexec_status()

PATCH In review Eric DeVolder 4 participants 5 messages Jan 19, 2017 – Jan 20, 2017

lore
Share & tools
lore
#0 lore raw

cover Followup corrections for kexec_status()

Jan,
This corrects the use of test_bit() in kexec_status().

Wei,
This patch is against the kexec_status() recently applied to staging.

Regards,
Eric

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

PATCH 1/1 kexec: ensure kexec_status() return bit value of 0 or 1

When checking kexec_flags bit corresponding to the requested image, ensure that 0 or 1 is returned.

---
 xen/common/kexec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/kexec.c +2 -1
index aa808cb..3da27bf 100644
@@ -1182,7 +1182,8 @@ static int kexec_status(XEN_GUEST_HANDLE_PARAM(void) uarg)
     if ( kexec_load_get_bits(status.type, &base, &bit) )
         return -EINVAL;
 
-    return test_bit(bit, &kexec_flags);
+    /* Ensure return bit value of 0 or 1 */
+    return !!test_bit(bit, &kexec_flags);
 }
 
 static int do_kexec_op_internal(unsigned long op,
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH 1/1] kexec: ensure kexec_status() return bit value of 0 or 1

Quoted 4 lines · Eric DeVolder

When checking kexec_flags bit corresponding to the requested image, ensure that 0 or 1 is returned.

In general Reviewed-by: Daniel Kiper <[email protected]> but...

Quoted 9 lines
---
 xen/common/kexec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/kexec.c +0 -0
index aa808cb..3da27bf 100644

xen/common/kexec.c static int kexec_status(XEN_GUEST_HANDLE_PARAM(void) uarg) · line 1185

Quoted 5 lines
xen/common/kexec.c +1 -1
@@ -1182,7 +1182,8 @@ static int kexec_status(XEN_GUEST_HANDLE_PARAM(void) uarg)
     if ( kexec_load_get_bits(status.type, &base, &bit) )
         return -EINVAL;
 
-    return test_bit(bit, &kexec_flags);
+    /* Ensure return bit value of 0 or 1 */

This is not needed here. "!!" is used very often and it is not an unusual stuff. So, it does not need any comment. However, I can agree that at first sight it looks strange.

xen/common/kexec.c static int kexec_status(XEN_GUEST_HANDLE_PARAM(void) uarg) · line 1186

Quoted 1 line
xen/common/kexec.c +1 -0
+    return !!test_bit(bit, &kexec_flags);

Daniel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH 1/1] kexec: ensure kexec_status() return bit value of 0 or 1

In reply to Eric DeVolder

xen/common/kexec.c static int kexec_status(XEN_GUEST_HANDLE_PARAM(void) uarg) · line 1187

Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 19.01.17 at 18:10, <[email protected]> wrote:
xen/common/kexec.c +2 -1
@@ -1182,7 +1182,8 @@ static int kexec_status(XEN_GUEST_HANDLE_PARAM(void) uarg)
     if ( kexec_load_get_bits(status.type, &base, &bit) )
         return -EINVAL;
 
-    return test_bit(bit, &kexec_flags);
+    /* Ensure return bit value of 0 or 1 */
+    return !!test_bit(bit, &kexec_flags);
 }

I don't see the point of adding a comment here, but I'll let Andrew as the maintainer judge. In any event

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#4 lore raw

Re: [PATCH 1/1] kexec: ensure kexec_status() return bit value of 0 or 1

In reply to Eric DeVolder
Quoted 4 lines · Eric DeVolder

When checking kexec_flags bit corresponding to the requested image, ensure that 0 or 1 is returned.

dropped the commit while doing so

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel