Skip to contentSkip to conversation

extras/mini-os/tpmback.c : fix compilation error.

PATCH In review Dushyant Behl 3 participants 3 messages Jul 20, 2014 – Jul 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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. Now the value is read into an actual int variable and then assigned to the enum.

---
 extras/mini-os/tpmback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
extras/mini-os/tpmback.c +3 -1
index 0601eb3..31da8d5 100644
@@ -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 */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 9 lines · Dushyant Behl, le Mon 21 Jul 2014 02:22:59 +0530, a écrit :

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. Now the value is read into an actual int variable and then assigned to the enum.

Quoted 33 lines
---
 extras/mini-os/tpmback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
extras/mini-os/tpmback.c +3 -1
index 0601eb3..31da8d5 100644
@@ -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 */
Signature · 1 line
1.9.1
Signature · 5 lines
Samuel
 Profitant de cette occasion, vous serait-il possible de rebooter 
 aussi Modérator et son petit copain qui gère les ressources de 
 download ?
 -+- OB in NPC : Apprendre à flasher son personnel -+-
#2 lore raw
Quoted 4 lines · Samuel Thibault
Quoted 3 lines · Dushyant Behl, le Mon 21 Jul 2014 02:22:59 +0530, a écrit :

This patch is with respect to the following discussion on xen-devel -
http://lists.xenproject.org/archives/html/xen-devel/2014-07/msg01991.html

Quoted 8 lines
Quoted 6 lines

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. Now the value is read into an actual int variable and then assigned to the enum.

Applied. I added the actual build error message to the log as I did so.

Ian,

Quoted 30 lines
Quoted 30 lines
---
 extras/mini-os/tpmback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
extras/mini-os/tpmback.c +3 -1
index 0601eb3..31da8d5 100644
@@ -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);
 
Quoted 5 lines
Quoted 4 lines
extras/mini-os/tpmback.c +0 -0
    /* It's possible that the backend state got updated by hotplug or something else behind our back */
Signature · 1 line
1.9.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel