diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-01-23 09:36:29 -0600 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-01-25 21:05:41 +0000 |
commit | 5618105004bf4ccde0fd31ea48a2b760c9adfc0f (patch) | |
tree | 6bb3b19c202ce4b0402888d466f64af8eda4a528 | |
parent | 0573237f4521a0087153cded38814461c8978262 (diff) | |
download | phosphor-host-ipmid-5618105004bf4ccde0fd31ea48a2b760c9adfc0f.tar.gz phosphor-host-ipmid-5618105004bf4ccde0fd31ea48a2b760c9adfc0f.zip |
Correct compilation errors
Fix compilation errors found with later gcc version during integration
unit tests.
Resolves openbmc/phosphor-host-ipmid#101
Change-Id: I35c5433f03521a877fd09748b8262d6172d21535
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
-rw-r--r-- | chassishandler.cpp | 3 | ||||
-rw-r--r-- | storageaddsel.cpp | 15 |
2 files changed, 11 insertions, 7 deletions
diff --git a/chassishandler.cpp b/chassishandler.cpp index 4332f81..66a8cdd 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -124,7 +124,7 @@ int dbus_get_property(const char *name, char **buf) goto finish; } - asprintf(buf, "%s", temp_buf); + *buf = strdup(temp_buf); /* *buf = (char*) malloc(strlen(temp_buf)); if (*buf) { strcpy(*buf, temp_buf); @@ -1070,4 +1070,3 @@ void register_netfn_chassis_functions() ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_SET_SYS_BOOT_OPTIONS, NULL, ipmi_chassis_set_sys_boot_options, PRIVILEGE_OPERATOR); } - diff --git a/storageaddsel.cpp b/storageaddsel.cpp index 87018e7..84e3092 100644 --- a/storageaddsel.cpp +++ b/storageaddsel.cpp @@ -53,21 +53,21 @@ int find_sensor_type_string(uint8_t sensor_number, char **s) { dbus_interface_t a; const char *p; - char r; + int r; r = find_openbmc_path("SENSOR", sensor_number, &a); if ((r < 0) || (a.bus[0] == 0)) { // Just make a generic message for errors that // occur on sensors that dont exist - asprintf(s, "Unknown Sensor (0x%02x)", sensor_number); + r = asprintf(s, "Unknown Sensor (0x%02x)", sensor_number); } else { if ((p = strrchr (a.path, '/')) == NULL) { p = "/Unknown Sensor"; } - asprintf(s, "%s", p+1); + *s = strdup(p+1); } return 0; @@ -145,7 +145,7 @@ int create_esel_association(const uint8_t *buffer, char **m) { memset(dbusint.path,0,sizeof(dbusint.path)); } - asprintf(m, "%s", dbusint.path); + *m = strdup(dbusint.path); return 0; } @@ -157,12 +157,17 @@ int create_esel_description(const uint8_t *buffer, const char *sev, char **messa ipmi_add_sel_request_t *p; char *m; + int r; p = ( ipmi_add_sel_request_t *) buffer; find_sensor_type_string(p->sensornumber,&m); - asprintf(message, "A %s has experienced a %s", m, sev ); + r = asprintf(message, "A %s has experienced a %s", m, sev ); + if (r == -1) { + fprintf(stderr, + "Failed to allocate memory for ESEL description\n"); + } free(m); |