From 799a402c37052a17c74ccfff8ac23a05141e057e Mon Sep 17 00:00:00 2001 From: Michael Shych Date: Thu, 15 Dec 2016 17:09:37 +0000 Subject: [PATCH] Changes in usage of onlp_file_read/onlp_file_write APIs. Signed-off-by: Michael Shych --- .../onlp/builds/src/module/src/fani.c | 14 ++++--------- .../onlp/builds/src/module/src/ledi.c | 13 ++++-------- .../onlp/builds/src/module/src/psui.c | 10 ++++------ .../onlp/builds/src/module/src/thermali.c | 7 ++----- .../onlp/builds/src/module/src/fani.c | 20 ++++++------------- .../onlp/builds/src/module/src/ledi.c | 12 ++++------- .../onlp/builds/src/module/src/platform_lib.c | 5 ++--- .../onlp/builds/src/module/src/psui.c | 10 ++++------ .../onlp/builds/src/module/src/thermali.c | 7 ++----- .../onlp/builds/src/module/src/fani.c | 19 +++++------------- .../onlp/builds/src/module/src/ledi.c | 12 ++++------- .../onlp/builds/src/module/src/platform_lib.c | 5 ++--- .../onlp/builds/src/module/src/psui.c | 10 ++++------ .../onlp/builds/src/module/src/thermali.c | 7 ++----- 14 files changed, 49 insertions(+), 102 deletions(-) diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c index 7dd59e0d..931d6b0d 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/fani.c @@ -213,7 +213,6 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) float temp = 0.0; int rv = 0, local_id = 0, nbytes = 10; char r_data[10] = {0}; - char fullpath[LEN_FILE_NAME] = {0}; onlp_fan_info_t* info = NULL; VALIDATE(id); @@ -230,9 +229,6 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) return ONLP_STATUS_E_INVALID; } - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - /* Set fan speed Converting percent to driver value. Driver accept value in range between 153 and 255. @@ -254,7 +250,8 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + fan_path[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -276,7 +273,6 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) float temp = 0.0; int rv = 0, local_id = 0, nbytes = 10; char r_data[10] = {0}; - char fullpath[LEN_FILE_NAME] = {0}; onlp_fan_info_t* info = NULL; VALIDATE(id); @@ -296,9 +292,6 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) return ONLP_STATUS_E_PARAM; } - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - /* Set fan speed Converting percent to driver value. Driver accept value in range between 153 and 255. @@ -310,7 +303,8 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", + PREFIX_PATH, fan_path[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c index 459207e7..6966e6bd 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/ledi.c @@ -200,20 +200,17 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { int len, local_id = 0; uint8_t data[driver_value_len] = {0}; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - /* get fullpath */ - snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]); - /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[ONLP_OID_ID_GET(id)]; /* Get LED mode */ - if (onlp_file_read(data, sizeof(data), &len, fullpath) != 0) { + if (onlp_file_read(data, sizeof(data), &len, "%s%s", + prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; } @@ -258,15 +255,13 @@ int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { int local_id; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]); - if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, fullpath) != 0) - { + if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, + "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c index e48cee9f..8bfc5357 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/psui.c @@ -49,12 +49,11 @@ psu_module_info_get(int id, char *node, int *value) { int len, ret = 0; char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; - sprintf(node_path, PSU_MODULE_PREFIX, id, node); - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path); + ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, + PSU_MODULE_PREFIX, id, node); if (ret == 0) { *value = atoi(buf); } @@ -67,12 +66,11 @@ psu_power_info_get(int id, char *node, int *value) { int len, ret = 0; char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; - sprintf(node_path, PSU_POWER_PREFIX, id, node); - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path); + ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, + PSU_POWER_PREFIX, id, node); if (ret == 0) { *value = atoi(buf); } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c index 32b9d254..faaa08c8 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c @@ -146,7 +146,6 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) { int rv, len = 10, temp_base=1, local_id = 0; char r_data[10] = {0}; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); @@ -154,10 +153,8 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[local_id]; - /* get fullpath */ - snprintf(fullpath, sizeof(fullpath), "%s/%s", prefix_path, last_path[local_id]); - - rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, fullpath); + rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, "%s/%s", + prefix_path, last_path[local_id]); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c index dfcb39c9..a1e23036 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/fani.c @@ -166,7 +166,6 @@ _onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) uint8_t temp = 0; int rv = 0; int len = 0; - char path[LEN_FILE_NAME] = {0}; /* We have 4 FRU with 2 fans(total 8 fans). Eeprom is per FRU but not per fan. @@ -177,9 +176,8 @@ _onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) local_id /= 2; } - /* Reading FRU eeprom. */ - snprintf(path, sizeof(path), IDPROM_PATH, "fan", local_id); - rv = onlp_file_read(data, sizeof(data), &len, path); + rv = onlp_file_read(data, sizeof(data), &len, + IDPROM_PATH, "fan", local_id); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -401,7 +399,6 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) float temp = 0.0; int rv = 0, local_id = 0, nbytes = 10; char r_data[10] = {0}; - char fullpath[LEN_FILE_NAME] = {0}; onlp_fan_info_t* info = NULL; VALIDATE(id); @@ -418,9 +415,6 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) return ONLP_STATUS_E_INVALID; } - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - /* Set fan speed Converting percent to driver value. Driver accept value in range between 153 and 255. @@ -442,7 +436,8 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + fan_path[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -464,7 +459,6 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) float temp = 0.0; int rv = 0, local_id = 0, nbytes = 10; char r_data[10] = {0}; - char fullpath[LEN_FILE_NAME] = {0}; onlp_fan_info_t* info = NULL; VALIDATE(id); @@ -484,9 +478,6 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) return ONLP_STATUS_E_PARAM; } - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - /* Set fan speed Converting percent to driver value. Driver accept value in range between 153 and 255. @@ -498,7 +489,8 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + fan_path[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c index 27b39485..592d58e1 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/ledi.c @@ -217,20 +217,17 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { int len, local_id = 0; uint8_t data[driver_value_len] = {0}; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - /* get fullpath */ - snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]); - /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[ONLP_OID_ID_GET(id)]; /* Get LED mode */ - if (onlp_file_read(data, sizeof(data), &len, fullpath) != 0) { + if (onlp_file_read(data, sizeof(data), &len, "%s%s", + prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; } @@ -275,14 +272,13 @@ int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { int local_id; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]); - if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, fullpath) != 0) + if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, + "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c index c0c1765e..5ee85a2a 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/platform_lib.c @@ -35,15 +35,14 @@ int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_info) { - char path[64] = {0}; const char sanity_check[] = "MLNX"; const uint8_t serial_len = 24; char data[256] = {0}; bool sanity_found = false; int index = 0, rv = 0, len = 0; - snprintf(path, sizeof(path), IDPROM_PATH, "psu", psu_index); - rv = onlp_file_read((uint8_t* )data, sizeof(data)-1, &len, path); + rv = onlp_file_read((uint8_t* )data, sizeof(data)-1, &len, + IDPROM_PATH, "psu", psu_index); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c index 610b034e..ff734bdc 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/psui.c @@ -47,12 +47,11 @@ psu_module_info_get(int id, char *node, int *value) { int len, ret = 0; char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; - sprintf(node_path, PSU_MODULE_PREFIX, id, node); - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path); + ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, + PSU_MODULE_PREFIX, id, node); if (ret == 0) { *value = atoi(buf); } @@ -65,12 +64,11 @@ psu_power_info_get(int id, char *node, int *value) { int len, ret = 0; char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; - sprintf(node_path, PSU_POWER_PREFIX, id, node); - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path); + ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, + PSU_POWER_PREFIX, id, node); if (ret == 0) { *value = atoi(buf); } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c index d2e1a533..7b563eec 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c @@ -156,7 +156,6 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) { int rv, len = 10, temp_base=1, local_id = 0; char r_data[10] = {0}; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); @@ -164,10 +163,8 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[local_id]; - /* get fullpath */ - snprintf(fullpath, sizeof(fullpath), "%s/%s", prefix_path, last_path[local_id]); - - rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, fullpath); + rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, + "%s/%s", prefix_path, last_path[local_id]); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c index dfcb39c9..c5840918 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/fani.c @@ -166,7 +166,6 @@ _onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) uint8_t temp = 0; int rv = 0; int len = 0; - char path[LEN_FILE_NAME] = {0}; /* We have 4 FRU with 2 fans(total 8 fans). Eeprom is per FRU but not per fan. @@ -177,9 +176,7 @@ _onlp_fani_read_fan_eeprom(int local_id, onlp_fan_info_t* info) local_id /= 2; } - /* Reading FRU eeprom. */ - snprintf(path, sizeof(path), IDPROM_PATH, "fan", local_id); - rv = onlp_file_read(data, sizeof(data), &len, path); + rv = onlp_file_read(data, sizeof(data), &len, IDPROM_PATH, "fan", local_id); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -401,7 +398,6 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) float temp = 0.0; int rv = 0, local_id = 0, nbytes = 10; char r_data[10] = {0}; - char fullpath[LEN_FILE_NAME] = {0}; onlp_fan_info_t* info = NULL; VALIDATE(id); @@ -418,9 +414,6 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) return ONLP_STATUS_E_INVALID; } - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - /* Set fan speed Converting percent to driver value. Driver accept value in range between 153 and 255. @@ -442,7 +435,8 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + fan_path[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -464,7 +458,6 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) float temp = 0.0; int rv = 0, local_id = 0, nbytes = 10; char r_data[10] = {0}; - char fullpath[LEN_FILE_NAME] = {0}; onlp_fan_info_t* info = NULL; VALIDATE(id); @@ -484,9 +477,6 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) return ONLP_STATUS_E_PARAM; } - snprintf(fullpath, sizeof(fullpath), "%s%s", PREFIX_PATH, - fan_path[local_id].r_speed_set); - /* Set fan speed Converting percent to driver value. Driver accept value in range between 153 and 255. @@ -498,7 +488,8 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, fullpath); + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + fan_path[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c index c8b71de3..bdc4d56a 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/ledi.c @@ -217,20 +217,17 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { int len, local_id = 0; uint8_t data[driver_value_len] = {0}; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - /* get fullpath */ - snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]); - /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[ONLP_OID_ID_GET(id)]; /* Get LED mode */ - if (onlp_file_read(data, sizeof(data), &len, fullpath) != 0) { + if (onlp_file_read(data, sizeof(data), &len, "%s%s", + prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; } @@ -275,14 +272,13 @@ int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { int local_id; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); - snprintf(fullpath, sizeof(fullpath), "%s%s", prefix_path, file_names[local_id]); - if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, fullpath) != 0) + if (onlp_file_write((uint8_t*)onlp_to_driver_led_mode(local_id, mode), driver_value_len, + "%s%s", prefix_path, file_names[local_id]) != 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c index c0c1765e..5ee85a2a 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/platform_lib.c @@ -35,15 +35,14 @@ int psu_read_eeprom(int psu_index, onlp_psu_info_t* psu_info, onlp_fan_info_t* fan_info) { - char path[64] = {0}; const char sanity_check[] = "MLNX"; const uint8_t serial_len = 24; char data[256] = {0}; bool sanity_found = false; int index = 0, rv = 0, len = 0; - snprintf(path, sizeof(path), IDPROM_PATH, "psu", psu_index); - rv = onlp_file_read((uint8_t* )data, sizeof(data)-1, &len, path); + rv = onlp_file_read((uint8_t* )data, sizeof(data)-1, &len, + IDPROM_PATH, "psu", psu_index); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c index 610b034e..ff734bdc 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/psui.c @@ -47,12 +47,11 @@ psu_module_info_get(int id, char *node, int *value) { int len, ret = 0; char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; - sprintf(node_path, PSU_MODULE_PREFIX, id, node); - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path); + ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, + PSU_MODULE_PREFIX, id, node); if (ret == 0) { *value = atoi(buf); } @@ -65,12 +64,11 @@ psu_power_info_get(int id, char *node, int *value) { int len, ret = 0; char buf[PSU_NODE_MAX_INT_LEN + 1] = {0}; - char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; *value = 0; - sprintf(node_path, PSU_POWER_PREFIX, id, node); - ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, node_path); + ret = onlp_file_read((uint8_t*)buf, sizeof(buf), &len, + PSU_POWER_PREFIX, id, node); if (ret == 0) { *value = atoi(buf); } diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c index d2e1a533..698be008 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c @@ -156,7 +156,6 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) { int rv, len = 10, temp_base=1, local_id = 0; char r_data[10] = {0}; - char fullpath[50] = {0}; VALIDATE(id); local_id = ONLP_OID_ID_GET(id); @@ -164,10 +163,8 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) /* Set the onlp_oid_hdr_t and capabilities */ *info = linfo[local_id]; - /* get fullpath */ - snprintf(fullpath, sizeof(fullpath), "%s/%s", prefix_path, last_path[local_id]); - - rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, fullpath); + rv = onlp_file_read((uint8_t*)r_data, sizeof(r_data), &len, "%s/%s", + prefix_path, last_path[local_id]); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; }