Patch 1 for lib/ipmi_fru.c based on

On Mon, Apr 29, 2013 at 9:01 PM, Dan Gora <d...@adax.com> wrote:
> Hi All,
>
> Following are 5 patches to fix the compilation warnings which appear
> in newer gcc versions (gcc 4.7.2 currently only seen in Ububtu 12.10
> AFAIK) when -Wno-unused-return is removed from the compilation flags.
>
> -Wno-unused-return basically _has_ to come out.  A few compilation
> warnings are better than having the compilation just fail with older
> gcc versions.  Hopefully these patches will fix the compilation
> warnings to everyone's satisfaction.
>
> thanks
> dan
From bcb7b3b72bc4fdb6b03a93956e0f09027fa389f0 Mon Sep 17 00:00:00 2001
From: Dan Gora <d...@adax.com>
Date: Mon, 29 Apr 2013 19:51:02 -0300
Subject: [PATCH 1/6] Fixed warnings due to removing -Wno-unused-return in
 lib/ipmi_fru.c

---
 ipmitool/lib/ipmi_fru.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/ipmitool/lib/ipmi_fru.c b/ipmitool/lib/ipmi_fru.c
index 7af3e5b..a6e3fd4 100644
--- a/ipmitool/lib/ipmi_fru.c
+++ b/ipmitool/lib/ipmi_fru.c
@@ -1555,24 +1555,31 @@ fru_area_print_multirec(struct ipmi_intf * intf, struct 
fru_info * fru,
 int ipmi_fru_query_new_value(uint8_t *data,int offset, size_t len)
 {
        int status=FALSE;
+       int ret;
        char answer;
 
-
        printf("Would you like to change this value <y/n> ? ");
-
-       scanf("%c",&answer);
+       ret = scanf("%c",&answer);
+       if (ret != 1)
+               return FALSE;
 
        if( answer == 'y' || answer == 'Y' ){
                int i;
                unsigned int *holder;
 
                holder = malloc(len);
-               printf("Enter hex values for each of the %d entries (lsb 
first),"   \
-                               " hit <enter> between entries\n",len);
+               printf(
+                "Enter hex values for each of the %d entries (lsb first), "
+                "hit <enter> between entries\n", (int)len);
 
                /* I can't assign scanf' %x into a single char */
                for( i=0;i<len;i++ ){
-                       scanf("%x",holder+i);
+                       ret = scanf("%x",holder+i);
+                       if (ret != 1)
+                               {
+                               free(holder);
+                               return FALSE;
+                               }
                }
                for( i=0;i<len;i++ ){
                        data[offset++] = (unsigned char) *(holder+i);
-- 
1.7.11

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to