diff mbox

[14/21] dm: replace abbrev branching with goto

Message ID 20161009133056.GA3900@obsidian (mailing list archive)
State Not Applicable, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Eugene Syromyatnikov Oct. 9, 2016, 1:30 p.m. UTC
---
 dm.c |   78 ++++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 40 insertions(+), 38 deletions(-)
diff mbox

Patch

diff --git a/dm.c b/dm.c
index 73a9b57..814d7d2 100644
--- a/dm.c
+++ b/dm.c
@@ -350,52 +350,54 @@  dm_known_ioctl(struct tcb *tcp, const unsigned int code, long arg)
 			}
 		}
 	}
-	if (abbrev(tcp))
+
+	if (abbrev(tcp)) {
 		tprints(", ...");
-	else
-		switch (code) {
-		case DM_DEV_WAIT:
-		case DM_TABLE_STATUS:
-			if (entering(tcp) || syserror(tcp))
-				break;
-			dm_decode_dm_target_spec(tcp, ioc, extra, extra_size);
-			break;
-		case DM_TABLE_LOAD:
-			if (!entering(tcp))
-				break;
-			dm_decode_dm_target_spec(tcp, ioc, extra, extra_size);
+		goto skip;
+	}
+
+	switch (code) {
+	case DM_DEV_WAIT:
+	case DM_TABLE_STATUS:
+		if (entering(tcp) || syserror(tcp))
 			break;
-		case DM_TABLE_DEPS:
-			if (entering(tcp) || syserror(tcp))
-				break;
-			dm_decode_dm_target_deps(ioc, extra, extra_size);
+		dm_decode_dm_target_spec(tcp, ioc, extra, extra_size);
+		break;
+	case DM_TABLE_LOAD:
+		if (!entering(tcp))
 			break;
-		case DM_LIST_DEVICES:
-			if (entering(tcp) || syserror(tcp))
-				break;
-			dm_decode_dm_name_list(ioc, extra, extra_size);
+		dm_decode_dm_target_spec(tcp, ioc, extra, extra_size);
+		break;
+	case DM_TABLE_DEPS:
+		if (entering(tcp) || syserror(tcp))
 			break;
-		case DM_LIST_VERSIONS:
-			if (entering(tcp) || syserror(tcp))
-				break;
-			dm_decode_dm_target_versions(ioc, extra, extra_size);
+		dm_decode_dm_target_deps(ioc, extra, extra_size);
+		break;
+	case DM_LIST_DEVICES:
+		if (entering(tcp) || syserror(tcp))
 			break;
-		case DM_TARGET_MSG:
-			if (entering(tcp)) {
-				dm_decode_dm_target_msg(ioc, extra,
-							extra_size);
-			} else if (!syserror(tcp) &&
-			    ioc->flags & DM_DATA_OUT_FLAG) {
-				dm_decode_string(ioc, extra, extra_size);
-			}
+		dm_decode_dm_name_list(ioc, extra, extra_size);
+		break;
+	case DM_LIST_VERSIONS:
+		if (entering(tcp) || syserror(tcp))
 			break;
-		case DM_DEV_RENAME:
-		case DM_DEV_SET_GEOMETRY:
-			if (!entering(tcp))
-				break;
+		dm_decode_dm_target_versions(ioc, extra, extra_size);
+		break;
+	case DM_TARGET_MSG:
+		if (entering(tcp)) {
+			dm_decode_dm_target_msg(ioc, extra,
+						extra_size);
+		} else if (!syserror(tcp) && ioc->flags & DM_DATA_OUT_FLAG) {
 			dm_decode_string(ioc, extra, extra_size);
-			break;
 		}
+		break;
+	case DM_DEV_RENAME:
+	case DM_DEV_SET_GEOMETRY:
+		if (!entering(tcp))
+			break;
+		dm_decode_string(ioc, extra, extra_size);
+		break;
+	}
 
  skip:
 	tprints("}");