[lxc-devel] [PATCH] lxc-clone: proper type for getopt_long result

Bogdan Purcareata bogdan.purcareata at freescale.com
Mon Dec 9 14:39:46 UTC 2013


While char is a signed type and should have no trouble
storing a "-1" value, getopt_long() will return a value of 255
instead of -1. This has been noticed on powerpc; there's also
some upstream talk about it at [1].

Change variable type from char to int, since it's also the
documented use.

[1] http://stackoverflow.com/questions/17070958/c-why-does-getopt-return-255-on-linux

Signed-off-by: Bogdan Purcareata <bogdan.purcareata at freescale.com>
---
 src/lxc/lxc_clone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc_clone.c b/src/lxc/lxc_clone.c
index 4639a90..88a768d 100644
--- a/src/lxc/lxc_clone.c
+++ b/src/lxc/lxc_clone.c
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
 	char *bdevtype = NULL, *lxcpath = NULL, *newpath = NULL, *fstype = NULL;
 	char *orig = NULL, *new = NULL, *vgname = NULL;
 	char **args = NULL;
-	char c;
+	int c;
 
 	if (argc < 3)
 		usage(argv[0]);
-- 
1.7.11.7




More information about the lxc-devel mailing list