[PATCH phosphor-host-ipmid] fix set sel time

Patrick Williams patrick at stwcx.xyz
Tue Nov 24 06:51:57 AEDT 2015


On Thu, Nov 19, 2015 at 06:00:26PM -0500, OpenBMC Patches wrote:
> From: Norman James <njames at us.ibm.com>
> 
> ---
>  storagehandler.C | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/storagehandler.C b/storagehandler.C
> index 1459f94..71ed29c 100644
> --- a/storagehandler.C
> +++ b/storagehandler.C
> @@ -2,6 +2,7 @@
>  #include <string.h>
>  #include <stdint.h>
>  #include <time.h>
> +#include <sys/time.h>
>  #include <arpa/inet.h>
>  
>  #include "storagehandler.h"
> @@ -57,9 +58,20 @@ ipmi_ret_t ipmi_storage_set_sel_time(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
>      printf("Handling Set-SEL-Time:[0x%X], Cmd:[0x%X]\n",netfn, cmd);
>      printf("Data: 0x%X]\n",*bufftype);
>  
> -    g_sel_time = *bufftype;
> -
> +    struct timeval sel_time;
> +    sel_time.tv_sec = *bufftype;

This needs to have endianness fixed.  I think:
    le32toh(*bufftype)

Also, on line 56 whoever did a cast to 'unsigned int' wrote non-portable
code.  This should either be uint32_t or uint16_t.  That will also tell
you which function you should be using for the endianness conversion.

>      ipmi_ret_t rc = IPMI_CC_OK;
> +    int rct = settimeofday(&sel_time, NULL);
> +
> +    if(rct == 0)
> +    {
> +	system("hwclock -w");
> +    }
> +    else
> +    {
> +        printf("settimeofday() failed\n");
> +        rc = IPMI_CC_UNSPECIFIED_ERROR;
> +    }
>      *data_len = 0;
>      return rc;
>  }
> -- 
> 2.6.3
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

-- 
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20151123/4ab90e02/attachment.sig>


More information about the openbmc mailing list