xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] extras/mini-os/tpmback.c : fix compilation error.
@ 2014-07-20 20:52 Dushyant Behl
  2014-07-20 21:02 ` Samuel Thibault
  0 siblings, 1 reply; 3+ messages in thread
From: Dushyant Behl @ 2014-07-20 20:52 UTC (permalink / raw)
  To: "Xen Devel
  Cc: Ian Campbell, Stefano Stabellini, Ian Jackson, Samuel Thibault,
	Daniel De Graaf, Dushyant Behl

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.

Signed-off-by:- Dushyant Behl <myselfdushyantbehl@gmail.com>
---
 extras/mini-os/tpmback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/extras/mini-os/tpmback.c b/extras/mini-os/tpmback.c
index 0601eb3..31da8d5 100644
--- a/extras/mini-os/tpmback.c
+++ b/extras/mini-os/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 */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] extras/mini-os/tpmback.c : fix compilation error.
  2014-07-20 20:52 [PATCH] extras/mini-os/tpmback.c : fix compilation error Dushyant Behl
@ 2014-07-20 21:02 ` Samuel Thibault
  2014-07-21 11:43   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2014-07-20 21:02 UTC (permalink / raw)
  To: Dushyant Behl
  Cc: Daniel De Graaf, Stefano Stabellini, Ian Jackson, Ian Campbell,
	"Xen Devel

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.
> 
> Signed-off-by:- Dushyant Behl <myselfdushyantbehl@gmail.com>

Ack-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  extras/mini-os/tpmback.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/extras/mini-os/tpmback.c b/extras/mini-os/tpmback.c
> index 0601eb3..31da8d5 100644
> --- a/extras/mini-os/tpmback.c
> +++ b/extras/mini-os/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 */
> -- 
> 1.9.1
> 

-- 
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 -+-

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] extras/mini-os/tpmback.c : fix compilation error.
  2014-07-20 21:02 ` Samuel Thibault
@ 2014-07-21 11:43   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2014-07-21 11:43 UTC (permalink / raw)
  To: Samuel Thibault
  Cc: Ian Jackson, Daniel De Graaf, Stefano Stabellini, Dushyant Behl,
	"Xen Devel

On Sun, 2014-07-20 at 23:02 +0200, Samuel Thibault wrote:
> 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.
> > 
> > Signed-off-by:- Dushyant Behl <myselfdushyantbehl@gmail.com>
> 
> Ack-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

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

Ian,
> 
> > ---
> >  extras/mini-os/tpmback.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/extras/mini-os/tpmback.c b/extras/mini-os/tpmback.c
> > index 0601eb3..31da8d5 100644
> > --- a/extras/mini-os/tpmback.c
> > +++ b/extras/mini-os/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 */
> > -- 
> > 1.9.1
> > 
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-21 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-20 20:52 [PATCH] extras/mini-os/tpmback.c : fix compilation error Dushyant Behl
2014-07-20 21:02 ` Samuel Thibault
2014-07-21 11:43   ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).