]> granicus.if.org Git - strace/commitdiff
scsi: prepare for decoding of other SG_* ioctl commands
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 9 Jan 2017 13:53:27 +0000 (13:53 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 10 Jan 2017 00:05:17 +0000 (00:05 +0000)
* scsi.c (scsi_ioctl): Introduce a switch statement.

scsi.c

diff --git a/scsi.c b/scsi.c
index 7da6dece246d660e8efa46b155bc565941fd0819..1f6fafa37d948c9b80420cbf5d5f7a09ab747924 100644 (file)
--- a/scsi.c
+++ b/scsi.c
@@ -54,23 +54,27 @@ int
 scsi_ioctl(struct tcb *const tcp, const unsigned int code,
           const kernel_ulong_t arg)
 {
-       if (SG_IO != code)
-               return RVAL_DECODED;
-
-       if (entering(tcp)) {
-               uint32_t iid;
+       switch (code) {
+       case SG_IO:
+               if (entering(tcp)) {
+                       uint32_t iid;
 
-               tprints(", ");
-               if (umove_or_printaddr(tcp, arg, &iid)) {
-                       return RVAL_DECODED | 1;
+                       tprints(", ");
+                       if (umove_or_printaddr(tcp, arg, &iid)) {
+                               break;
+                       } else {
+                               return decode_sg_io(tcp, iid, arg);
+                       }
                } else {
-                       return decode_sg_io(tcp, iid, arg);
+                       uint32_t *piid = get_tcb_priv_data(tcp);
+                       if (piid)
+                               decode_sg_io(tcp, *piid, arg);
+                       tprints("}");
+                       break;
                }
-       } else {
-               uint32_t *piid = get_tcb_priv_data(tcp);
-               if (piid)
-                       decode_sg_io(tcp, *piid, arg);
-               tprints("}");
-               return RVAL_DECODED | 1;
+       default:
+               return RVAL_DECODED;
        }
+
+       return RVAL_DECODED | 1;
 }