Patch 6: Fix compilation warnings in ipmi_hpmfwupg.c

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 1d24975d343b4730a6d5f68fcc3913334f56baec Mon Sep 17 00:00:00 2001
From: Dan Gora <d...@adax.com>
Date: Tue, 2 Apr 2013 17:23:22 -0300
Subject: [PATCH 6/6] Fixed compilation warnings in lib/ipmi_hpmfwupg.c

Check the return code from scanf and fread as we should.
---
 ipmitool/lib/ipmi_hpmfwupg.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/ipmitool/lib/ipmi_hpmfwupg.c b/ipmitool/lib/ipmi_hpmfwupg.c
index 0ccde76..a564b6f 100644
--- a/ipmitool/lib/ipmi_hpmfwupg.c
+++ b/ipmitool/lib/ipmi_hpmfwupg.c
@@ -1103,8 +1103,13 @@ static int HpmFwupgActionUploadFirmware
 int HpmGetUserInput(char *str)
 {
     char userInput[2];
+    int ret;
+
     printf("%s", str);
-    scanf("%s",userInput);
+    ret = scanf("%s",userInput);
+    if (!ret)
+       return 1;
+
     if (toupper(userInput[0]) == 'Y')
     {
         return 1;
@@ -2602,6 +2607,7 @@ static int HpmfwupgActivationStage(struct ipmi_intf 
*intf, struct HpmfwupgUpgrad
 int HpmfwupgGetBufferFromFile(char* imageFilename, struct HpmfwupgUpgradeCtx* 
pFwupgCtx)
 {
    int rc = HPMFWUPG_SUCCESS;
+   int ret;
    FILE* pImageFile = fopen(imageFilename, "rb");
 
    if ( pImageFile == NULL )
@@ -2620,7 +2626,13 @@ int HpmfwupgGetBufferFromFile(char* imageFilename, 
struct HpmfwupgUpgradeCtx* pF
       rewind(pImageFile);
       if ( pFwupgCtx->pImageData != NULL )
       {
-         fread(pFwupgCtx->pImageData, sizeof(unsigned char), 
pFwupgCtx->imageSize, pImageFile);
+         ret = fread(pFwupgCtx->pImageData, sizeof(unsigned char), 
+               pFwupgCtx->imageSize, pImageFile);
+        if (ret != pFwupgCtx->imageSize) {
+               lprintf(LOG_ERROR,"Failed to read file %s size %d", 
+                       imageFilename, pFwupgCtx->imageSize);
+               rc = HPMFWUPG_ERROR;
+        }
       }
       else
       {
-- 
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