[CRIU] [PATCH] crtools: bump up the getopt return values to outside the ascii range

Filipe Brandenburger filbranden at google.com
Mon Aug 25 21:08:06 PDT 2014


The return values were getting dangerously close to the range of meaningful
values, in particular the next candidate 63 is equal to '?' which is the
typical return value in case of error.

The return values for long options may be any integer, so bump them up to
outside the ascii range, start above 1000. For ease of review this patch, keep
the existing range (41-62) and increment each value by 1000.

Tested:
- Ran "criu --help", works fine.
- Manual dump and restore with some of the options, worked fine.
- Ran the zdtm test suite, tests passed.

Signed-off-by: Filipe Brandenburger <filbranden at google.com>
---
 crtools.c | 84 +++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/crtools.c b/crtools.c
index afdc59bf4627..7c96acbbcfe6 100644
--- a/crtools.c
+++ b/crtools.c
@@ -147,32 +147,32 @@ int main(int argc, char *argv[])
 		{ "root", required_argument, 0, 'r' },
 		{ USK_EXT_PARAM, no_argument, 0, 'x' },
 		{ "help", no_argument, 0, 'h' },
-		{ SK_EST_PARAM, no_argument, 0, 42 },
-		{ "close", required_argument, 0, 43 },
-		{ "log-pid", no_argument, 0, 44},
+		{ SK_EST_PARAM, no_argument, 0, 1042 },
+		{ "close", required_argument, 0, 1043 },
+		{ "log-pid", no_argument, 0, 1044},
 		{ "version", no_argument, 0, 'V'},
-		{ "evasive-devices", no_argument, 0, 45},
-		{ "pidfile", required_argument, 0, 46},
-		{ "veth-pair", required_argument, 0, 47},
-		{ "action-script", required_argument, 0, 49},
-		{ LREMAP_PARAM, no_argument, 0, 41},
+		{ "evasive-devices", no_argument, 0, 1045},
+		{ "pidfile", required_argument, 0, 1046},
+		{ "veth-pair", required_argument, 0, 1047},
+		{ "action-script", required_argument, 0, 1049},
+		{ LREMAP_PARAM, no_argument, 0, 1041},
 		{ OPT_SHELL_JOB, no_argument, 0, 'j'},
 		{ OPT_FILE_LOCKS, no_argument, 0, 'l'},
-		{ "page-server", no_argument, 0, 50},
-		{ "address", required_argument, 0, 51},
-		{ "port", required_argument, 0, 52},
-		{ "prev-images-dir", required_argument, 0, 53},
-		{ "ms", no_argument, 0, 54},
-		{ "track-mem", no_argument, 0, 55},
-		{ "auto-dedup", no_argument, 0, 56},
+		{ "page-server", no_argument, 0, 1050},
+		{ "address", required_argument, 0, 1051},
+		{ "port", required_argument, 0, 1052},
+		{ "prev-images-dir", required_argument, 0, 1053},
+		{ "ms", no_argument, 0, 1054},
+		{ "track-mem", no_argument, 0, 1055},
+		{ "auto-dedup", no_argument, 0, 1056},
 		{ "libdir", required_argument, 0, 'L'},
-		{ "cpu-cap", required_argument, 0, 57},
-		{ "force-irmap", no_argument, 0, 58},
+		{ "cpu-cap", required_argument, 0, 1057},
+		{ "force-irmap", no_argument, 0, 1058},
 		{ "ext-mount-map", required_argument, 0, 'M'},
-		{ "exec-cmd", no_argument, 0, 59},
-		{ "manage-cgroups", no_argument, 0, 60},
-		{ "cgroup-root", required_argument, 0, 61},
-		{ "aufs-root", required_argument, 0, 62},
+		{ "exec-cmd", no_argument, 0, 1059},
+		{ "manage-cgroups", no_argument, 0, 1060},
+		{ "cgroup-root", required_argument, 0, 1061},
+		{ "aufs-root", required_argument, 0, 1062},
 		{ },
 	};
 
@@ -267,15 +267,15 @@ int main(int argc, char *argv[])
 			} else
 				log_level++;
 			break;
-		case 41:
+		case 1041:
 			pr_info("Will allow link remaps on FS\n");
 			opts.link_remap_ok = true;
 			break;
-		case 42:
+		case 1042:
 			pr_info("Will dump TCP connections\n");
 			opts.tcp_established_ok = true;
 			break;
-		case 43: {
+		case 1043: {
 			int fd;
 
 			fd = atoi(optarg);
@@ -283,16 +283,16 @@ int main(int argc, char *argv[])
 			close(fd);
 			break;
 		}
-		case 44:
+		case 1044:
 			opts.log_file_per_pid = 1;
 			break;
-		case 45:
+		case 1045:
 			opts.evasive_devices = true;
 			break;
-		case 46:
+		case 1046:
 			opts.pidfile = optarg;
 			break;
-		case 47:
+		case 1047:
 			{
 				char *aux;
 
@@ -305,7 +305,7 @@ int main(int argc, char *argv[])
 					return 1;
 			}
 			break;
-		case 49:
+		case 1049:
 			{
 				struct script *script;
 
@@ -317,13 +317,13 @@ int main(int argc, char *argv[])
 				list_add(&script->node, &opts.scripts);
 			}
 			break;
-		case 50:
+		case 1050:
 			opts.use_page_server = true;
 			break;
-		case 51:
+		case 1051:
 			opts.addr = optarg;
 			break;
-		case 52:
+		case 1052:
 			opts.ps_port = htons(atoi(optarg));
 			if (!opts.ps_port)
 				goto bad_arg;
@@ -334,35 +334,35 @@ int main(int argc, char *argv[])
 		case 'l':
 			opts.handle_file_locks = true;
 			break;
-		case 53:
+		case 1053:
 			opts.img_parent = optarg;
 			break;
-		case 55:
+		case 1055:
 			opts.track_mem = true;
 			break;
-		case 56:
+		case 1056:
 			opts.auto_dedup = true;
 			break;
-		case 57:
+		case 1057:
 			if (parse_cpu_cap(&opts, optarg))
 				goto usage;
 			break;
-		case 58:
+		case 1058:
 			opts.force_irmap = true;
 			break;
-		case 54:
+		case 1054:
 			opts.check_ms_kernel = true;
 			break;
 		case 'L':
 			opts.libdir = optarg;
 			break;
-		case 59:
+		case 1059:
 			has_exec_cmd = true;
 			break;
-		case 60:
+		case 1060:
 			opts.manage_cgroups = true;
 			break;
-		case 61:
+		case 1061:
 			{
 				char *path, *ctl;
 
@@ -401,7 +401,7 @@ int main(int argc, char *argv[])
 		case 'h':
 			usage_error = false;
 			goto usage;
-		case 62:
+		case 1062:
 			opts.aufs_root = optarg;
 			break;
 		default:
-- 
1.9.3



More information about the CRIU mailing list