From: Dushyant Behl Date: Sun, 20 Jul 2014 20:52:59 +0000 (+0530) Subject: extras/mini-os/tpmback.c: fix compilation error. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6fcd1e03dc3d7d1b20cf3a577343622f4e83ed6c;p=people%2Fliuw%2Flibxenctrl-split%2Fmini-os.git extras/mini-os/tpmback.c: fix compilation error. This patch is with respect to the following discussion on xen-devel - http://lists.xenproject.org/archives/html/xen-devel/2014-07/msg01991.html The file extras/mini-os/tpmback.c was failing compilation on certain compilers because of size mismatch between enum and int. Earlier the code used to read value of enum using %d format, which failed compilation on some compilers: tpmback.c: In function ‘tpmif_change_state’: tpmback.c:350:4: error: format ‘%d’ expects argument of type ‘int *’, but argument 3 has type ‘enum xenbus_state *’ [-Werror=format=] if(sscanf(value, "%d", &readst) != 1) { ^ Now the value is read into an actual int variable and then assigned to the enum. Signed-off-by:- Dushyant Behl Acked-by: Samuel Thibault [ ijc -- added the actual error to the commit log ] --- diff --git a/tpmback.c b/tpmback.c index 0601eb3..31da8d5 100644 --- a/tpmback.c +++ b/tpmback.c @@ -332,6 +332,7 @@ error_post_irq: * returns 0 on success and non-zero on error */ int tpmif_change_state(tpmif_t* tpmif, enum xenbus_state state) { + int tempst; char path[512]; char *value; char *err; @@ -347,11 +348,12 @@ int tpmif_change_state(tpmif_t* tpmif, enum xenbus_state state) free(err); return -1; } - if(sscanf(value, "%d", &readst) != 1) { + if(sscanf(value, "%d", &tempst) != 1) { TPMBACK_ERR("Non integer value (%s) in %s ??\n", value, path); free(value); return -1; } + readst = (enum xenbus_state) tempst; free(value); /* It's possible that the backend state got updated by hotplug or something else behind our back */