Skip to content

Commit

Permalink
[Edgecore][device][platform] Fixed Semgrep check error 1.
Browse files Browse the repository at this point in the history
Signed-off-by: michael_shih <[email protected]>
  • Loading branch information
ec-michael-shih committed Dec 2, 2022
1 parent cb06ad5 commit 4a47dd0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/time64.h>
#define __STDC_WANT_LIB_EXT1__ 1
#include <linux/string.h>

/***********************************************
* variable define
Expand Down Expand Up @@ -1079,7 +1081,11 @@ static char *show_date_time(void)
struct timespec64 tv;
struct tm tm_val;

#ifdef __STDC_LIB_EXT1__
memset_s(dmamem, DATETIME_LEN, 0, DATETIME_LEN);
#else
memset(g_datetime, 0, DATETIME_LEN);
#endif

ktime_get_real_ts64(&tv);
time64_to_tm(tv.tv_sec, 0, &tm_val);
Expand Down Expand Up @@ -2511,3 +2517,4 @@ module_exit(as9736_64d_pcie_fpga_exit);
MODULE_AUTHOR("Michael Shih <[email protected]>");
MODULE_DESCRIPTION("AS9734-64D READ EEPROM From FPGA via PCIE");
MODULE_LICENSE("GPL");

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/dmi.h>
#define __STDC_WANT_LIB_EXT1__ 1
#include <linux/string.h>

#define MAX_MODEL_NAME 12
#define MAX_SERIAL_NUMBER 11
Expand Down Expand Up @@ -274,8 +276,13 @@ static struct as9736_64d_psu_data *as9736_64d_psu_update_device(struct device *d
}

/* Read model name */
#ifdef __STDC_LIB_EXT1__
memset_s(data->model_name, sizeof(data->model_name), 0, sizeof(data->model_name));
memset_s(data->serial_number, sizeof(data->model_name), 0, sizeof(data->serial_number));
#else
memset(data->model_name, 0, sizeof(data->model_name));
memset(data->serial_number, 0, sizeof(data->serial_number));
#endif
power_good = (data->status_pwr_good >> (1-data->index) & 0x1);

if (power_good) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from sonic_py_common import logger
from threading import Lock
from typing import cast
from sonic_py_common.general import getstatusoutput_noshell_pipe

HOST_CHK_CMD = "which systemctl > /dev/null 2>&1"
EMPTY_STRING = ""
Expand Down Expand Up @@ -63,11 +64,8 @@ def ipmi_raw(self, netfn, cmd):
status = True
result = ""
try:
cmd = "ipmitool raw {} {}".format(str(netfn), str(cmd))
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'raw', str(netfn), str(cmd)])
if err == [0]:
result = raw_data.strip()
else:
status = False
Expand All @@ -79,13 +77,11 @@ def ipmi_fru_id(self, id, key=None):
status = True
result = ""
try:
cmd = "ipmitool fru print {}".format(str(
id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(id), str(key))

p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
if key == None:
err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'fru', 'print', str(id)])
else:
err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'fru', 'print', str(id)], ['grep', str(key)])
if err == [0] or err == [0, 0]:
result = raw_data.strip()
else:
status = False
Expand All @@ -97,11 +93,8 @@ def ipmi_set_ss_thres(self, id, threshold_key, value):
status = True
result = ""
try:
cmd = "ipmitool sensor thresh '{}' {} {}".format(str(id), str(threshold_key), str(value))
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
err, raw_data = getstatusoutput_noshell_pipe(['ipmitool', 'sensor', 'thresh', str(id), str(threshold_key), str(value)])
if err == [0]:
result = raw_data.strip()
else:
status = False
Expand Down Expand Up @@ -369,3 +362,4 @@ def set_low_critical_threshold(self, temperature):
raise ValueError('The parameter requires a float string. ex:\"30.1\"')

return self.__set_data(LOW_CRIT_THRESHOLD_FIELD, temperature)

0 comments on commit 4a47dd0

Please sign in to comment.