mirror of
https://github.com/openharmony/vendor_isoftstone.git
synced 2026-07-19 22:14:29 -04:00
@@ -1123,10 +1123,10 @@ uint8_t hw_lpm_enable(uint8_t turn_on)
|
||||
*p++ = LPM_CMD_PARAM_SIZE; /* parameter length */
|
||||
|
||||
if (turn_on) {
|
||||
memcpy(p, &lpm_param, LPM_CMD_PARAM_SIZE);
|
||||
memcpy_s(p, LPM_CMD_PARAM_SIZE, &lpm_param, LPM_CMD_PARAM_SIZE);
|
||||
upio_set(UPIO_LPM_MODE, UPIO_ASSERT, 0);
|
||||
} else {
|
||||
memset(p, 0, LPM_CMD_PARAM_SIZE);
|
||||
memset_s(p, LPM_CMD_PARAM_SIZE, 0, LPM_CMD_PARAM_SIZE);
|
||||
upio_set(UPIO_LPM_MODE, UPIO_DEASSERT, 0);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -107,7 +107,7 @@ static int rk_emmc_wait_busy(void)
|
||||
|
||||
busy = 0;
|
||||
do {
|
||||
memset(&cmd, 0, sizeof(struct mmc_command));
|
||||
memset_s(&cmd, sizeof(struct mmc_command), 0, sizeof(struct mmc_command));
|
||||
|
||||
cmd.opcode = MMC_SEND_STATUS;
|
||||
cmd.arg = this_card->rca << 16;
|
||||
|
||||
@@ -660,8 +660,8 @@ static u32 interpolate(int value, u32 *table, int size)
|
||||
d = (value - table[i - 1]) * (MAX_INTERPOLATE / (size - 1));
|
||||
d /= table[i] - table[i - 1];
|
||||
d = d + (i - 1) * (MAX_INTERPOLATE / (size - 1));
|
||||
} else {
|
||||
d = i * ((MAX_INTERPOLATE + size / 2) / size);
|
||||
} else if (size != 0) {
|
||||
d = i * ((MAX_INTERPOLATE + size / 2) / size);
|
||||
}
|
||||
|
||||
if (d > 1000) {
|
||||
@@ -2502,9 +2502,9 @@ static void rk817_bat_calc_zero_linek(struct rk817_battery_device *battery)
|
||||
voltage_avg = rk817_bat_get_battery_voltage(battery);
|
||||
current_avg = rk817_bat_get_avg_current(battery);
|
||||
vsys = voltage_avg + (current_avg * DEF_PWRPATH_RES) / 1000;
|
||||
|
||||
powerpatch_res = (voltage_avg - vsys) * 1000 / current_avg;
|
||||
|
||||
if (current_avg != 0) {
|
||||
powerpatch_res = (voltage_avg - vsys) * 1000 / current_avg;
|
||||
}
|
||||
battery->zero_voltage_avg = voltage_avg;
|
||||
battery->zero_current_avg = current_avg;
|
||||
battery->zero_vsys = vsys;
|
||||
|
||||
@@ -16,294 +16,299 @@
|
||||
#include <linux/blackbox_storage.h>
|
||||
|
||||
/* ---- local macroes ---- */
|
||||
#define BOOTLOADER_LOG_NAME "fastboot_log"
|
||||
#define KERNEL_LOG_NAME "last_kmsg"
|
||||
#define SIZE_1K 1024
|
||||
#define KERNEL_LOG_MAX_SIZE \
|
||||
round_up((0x80000 + sizeof(struct fault_log_info)), SIZE_1K)
|
||||
#define CALLSTACK_MAX_ENTRIES 20
|
||||
#define BOOTLOADER_LOG_NAME "fastboot_log"
|
||||
#define KERNEL_LOG_NAME "last_kmsg"
|
||||
#define SIZE_1K 1024
|
||||
#define KERNEL_LOG_MAX_SIZE round_up((0x80000 + sizeof(struct fault_log_info)), SIZE_1K)
|
||||
#define CALLSTACK_MAX_ENTRIES 20
|
||||
|
||||
/* ---- local prototypes ---- */
|
||||
|
||||
/* ---- local function prototypes ---- */
|
||||
static int save_kmsg_from_buffer(const char *log_dir,
|
||||
const char *file_name, int clean_buf);
|
||||
const char *file_name, int clean_buf);
|
||||
static void dump(const char *log_dir, struct error_info *info);
|
||||
static void reset(struct error_info *info);
|
||||
static int get_last_log_info(struct error_info *info);
|
||||
static int save_last_log(const char *log_dir, struct error_info *info);
|
||||
static int bbox_reboot_notify(struct notifier_block *nb,
|
||||
unsigned long code, void *unused);
|
||||
unsigned long code, void *unused);
|
||||
static int bbox_task_panic(struct notifier_block *this,
|
||||
unsigned long event, void *ptr);
|
||||
unsigned long event, void *ptr);
|
||||
|
||||
/* ---- local variables ---- */
|
||||
static char *kernel_log;
|
||||
static DEFINE_SEMAPHORE(kmsg_sem);
|
||||
static struct notifier_block bbox_reboot_nb = {
|
||||
.notifier_call = bbox_reboot_notify,
|
||||
.notifier_call = bbox_reboot_notify,
|
||||
};
|
||||
|
||||
static struct notifier_block bbox_panic_block = {
|
||||
.notifier_call = bbox_task_panic,
|
||||
.notifier_call = bbox_task_panic,
|
||||
};
|
||||
|
||||
/* ---- function definitions ---- */
|
||||
static void dump_stacktrace(char *pbuf, size_t buf_size, bool is_panic)
|
||||
{
|
||||
int i;
|
||||
size_t stack_len = 0;
|
||||
size_t com_len = 0;
|
||||
unsigned long entries[CALLSTACK_MAX_ENTRIES];
|
||||
unsigned int nr_entries;
|
||||
char tmp_buf[ERROR_DESC_MAX_LEN];
|
||||
bool find_panic = false;
|
||||
int i;
|
||||
size_t stack_len = 0;
|
||||
size_t com_len = 0;
|
||||
unsigned long entries[CALLSTACK_MAX_ENTRIES];
|
||||
unsigned int nr_entries;
|
||||
char tmp_buf[ERROR_DESC_MAX_LEN];
|
||||
bool find_panic = false;
|
||||
|
||||
if (unlikely(!pbuf || !buf_size))
|
||||
return;
|
||||
if (unlikely(!pbuf || !buf_size))
|
||||
return;
|
||||
|
||||
memset(pbuf, 0, buf_size);
|
||||
memset(tmp_buf, 0, sizeof(tmp_buf));
|
||||
nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
|
||||
com_len = scnprintf(pbuf, buf_size, "Comm:%s,CPU:%d,Stack:",
|
||||
current->comm, raw_smp_processor_id());
|
||||
for (i = 0; i < nr_entries; i++) {
|
||||
if (stack_len >= sizeof(tmp_buf)) {
|
||||
tmp_buf[sizeof(tmp_buf) - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
stack_len += scnprintf(tmp_buf + stack_len, sizeof(tmp_buf) - stack_len,
|
||||
"%pS-", (void *)entries[i]);
|
||||
if (!find_panic && is_panic) {
|
||||
if (strncmp(tmp_buf, "panic", strlen("panic")) == 0)
|
||||
find_panic = true;
|
||||
else
|
||||
(void)memset(tmp_buf, 0, sizeof(tmp_buf));
|
||||
}
|
||||
}
|
||||
if (com_len >= buf_size)
|
||||
return;
|
||||
stack_len = min(buf_size - com_len, strlen(tmp_buf));
|
||||
memcpy(pbuf + com_len, tmp_buf, stack_len);
|
||||
*(pbuf + buf_size - 1) = '\0';
|
||||
memset_s(pbuf, buf_size, 0, buf_size);
|
||||
memset_s(tmp_buf, sizeof(tmp_buf), 0, sizeof(tmp_buf));
|
||||
nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
|
||||
com_len = scnprintf(pbuf, buf_size, "Comm:%s,CPU:%d,Stack:",
|
||||
current->comm, raw_smp_processor_id());
|
||||
for (i = 0; i < nr_entries; i++) {
|
||||
if (stack_len >= sizeof(tmp_buf)) {
|
||||
tmp_buf[sizeof(tmp_buf) - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
stack_len += scnprintf(tmp_buf + stack_len, sizeof(tmp_buf) - stack_len,
|
||||
"%pS-", (void *)entries[i]);
|
||||
if (!find_panic && is_panic) {
|
||||
if (strncmp(tmp_buf, "panic", strlen("panic")) == 0)
|
||||
find_panic = true;
|
||||
else
|
||||
(void)memset_s(tmp_buf, sizeof(tmp_buf), 0, sizeof(tmp_buf));
|
||||
}
|
||||
}
|
||||
if (com_len >= buf_size)
|
||||
return;
|
||||
stack_len = min(buf_size - com_len, strlen(tmp_buf));
|
||||
errno_t err = EOK;
|
||||
if (pbuf + com_len == NULL || stack_len == 1) {
|
||||
return;
|
||||
}
|
||||
err = memcpy_s(pbuf + com_len, stack_len, tmp_buf, stack_len);
|
||||
if (err != EOK) {
|
||||
return;
|
||||
}
|
||||
*(pbuf + buf_size - 1) = '\0';
|
||||
}
|
||||
|
||||
static int save_kmsg_from_buffer(const char *log_dir,
|
||||
const char *file_name, int clean_buf)
|
||||
const char *file_name, int clean_buf)
|
||||
{
|
||||
int ret = -1;
|
||||
char path[PATH_MAX_LEN];
|
||||
struct fault_log_info *pinfo = NULL;
|
||||
int ret = -1;
|
||||
char path[PATH_MAX_LEN];
|
||||
struct fault_log_info *pinfo = NULL;
|
||||
|
||||
if (unlikely(!log_dir || !file_name)) {
|
||||
bbox_print_err("log_dir: %p, file_name: %p!\n", log_dir, file_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (unlikely(!log_dir || !file_name)) {
|
||||
bbox_print_err("log_dir: %p, file_name: %p!\n", log_dir, file_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
(void)scnprintf(path, sizeof(path) - 1, "%s/%s", log_dir, file_name);
|
||||
down(&kmsg_sem);
|
||||
if (kernel_log) {
|
||||
pinfo = (struct fault_log_info *)kernel_log;
|
||||
ret = full_write_file(path, kernel_log + sizeof(*pinfo),
|
||||
min(KERNEL_LOG_MAX_SIZE - sizeof(*pinfo),
|
||||
(size_t)pinfo->len), 0);
|
||||
if (clean_buf)
|
||||
memset(kernel_log, 0, KERNEL_LOG_MAX_SIZE);
|
||||
} else {
|
||||
bbox_print_err("kernel_log: %p!\n", kernel_log);
|
||||
}
|
||||
up(&kmsg_sem);
|
||||
memset_s(path, sizeof(path), 0, sizeof(path));
|
||||
(void)scnprintf(path, sizeof(path) - 1, "%s/%s", log_dir, file_name);
|
||||
down(&kmsg_sem);
|
||||
if (kernel_log) {
|
||||
pinfo = (struct fault_log_info *)kernel_log;
|
||||
ret = full_write_file(path, kernel_log + sizeof(*pinfo),
|
||||
min(KERNEL_LOG_MAX_SIZE - sizeof(*pinfo), (size_t)pinfo->len), 0);
|
||||
if (clean_buf)
|
||||
memset_s(kernel_log, KERNEL_LOG_MAX_SIZE, 0, KERNEL_LOG_MAX_SIZE);
|
||||
} else {
|
||||
bbox_print_err("kernel_log: %p!\n", kernel_log);
|
||||
}
|
||||
up(&kmsg_sem);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dump(const char *log_dir, struct error_info *info)
|
||||
{
|
||||
if (unlikely(!log_dir || !info)) {
|
||||
bbox_print_err("log_dir: %p, info: %p!\n", log_dir, info);
|
||||
return;
|
||||
}
|
||||
if (unlikely(!log_dir || !info)) {
|
||||
bbox_print_err("log_dir: %p, info: %p!\n", log_dir, info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp(info->category, CATEGORY_SYSTEM_PANIC) ||
|
||||
!strcmp(info->category, CATEGORY_SYSTEM_REBOOT) ||
|
||||
!strcmp(info->category, CATEGORY_SYSTEM_POWEROFF)) {
|
||||
struct fault_log_info *pinfo = (struct fault_log_info *)kernel_log;
|
||||
if (!strcmp(info->category, CATEGORY_SYSTEM_PANIC) ||
|
||||
!strcmp(info->category, CATEGORY_SYSTEM_REBOOT) ||
|
||||
!strcmp(info->category, CATEGORY_SYSTEM_POWEROFF)) {
|
||||
struct fault_log_info *pinfo = (struct fault_log_info *)kernel_log;
|
||||
|
||||
if (down_trylock(&kmsg_sem) != 0) {
|
||||
bbox_print_err("down_trylock failed!\n");
|
||||
return;
|
||||
}
|
||||
if (down_trylock(&kmsg_sem) != 0) {
|
||||
bbox_print_err("down_trylock failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (kernel_log) {
|
||||
memcpy(pinfo->flag, LOG_FLAG, strlen(LOG_FLAG));
|
||||
memcpy(&pinfo->info, info, sizeof(*info));
|
||||
if (kernel_log) {
|
||||
memcpy_s(pinfo->flag, strlen(LOG_FLAG), LOG_FLAG, strlen(LOG_FLAG));
|
||||
memcpy_s(&pinfo->info, sizeof(*info), info, sizeof(*info));
|
||||
|
||||
#if __BITS_PER_LONG == 64
|
||||
__flush_dcache_area(kernel_log, KERNEL_LOG_MAX_SIZE);
|
||||
__flush_dcache_area(kernel_log, KERNEL_LOG_MAX_SIZE);
|
||||
#else
|
||||
__cpuc_flush_dcache_area(kernel_log, KERNEL_LOG_MAX_SIZE);
|
||||
__cpuc_flush_dcache_area(kernel_log, KERNEL_LOG_MAX_SIZE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
up(&kmsg_sem);
|
||||
} else {
|
||||
bbox_print_info("module [%s] starts saving log for event [%s]!\n",
|
||||
info->module, info->event);
|
||||
save_kmsg_from_buffer(log_dir, KERNEL_LOG_NAME, 0);
|
||||
bbox_print_info("module [%s] ends saving log for event [%s]!\n",
|
||||
info->module, info->event);
|
||||
}
|
||||
up(&kmsg_sem);
|
||||
} else {
|
||||
bbox_print_info("module [%s] starts saving log for event [%s]!\n",
|
||||
info->module, info->event);
|
||||
save_kmsg_from_buffer(log_dir, KERNEL_LOG_NAME, 0);
|
||||
bbox_print_info("module [%s] ends saving log for event [%s]!\n",
|
||||
info->module, info->event);
|
||||
}
|
||||
}
|
||||
|
||||
static void reset(struct error_info *info)
|
||||
{
|
||||
if (unlikely(!info)) {
|
||||
bbox_print_err("info: %p!\n", info);
|
||||
return;
|
||||
}
|
||||
if (unlikely(!info)) {
|
||||
bbox_print_err("info: %p!\n", info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp(info->category, CATEGORY_SYSTEM_PANIC))
|
||||
emergency_restart();
|
||||
if (!strcmp(info->category, CATEGORY_SYSTEM_PANIC))
|
||||
emergency_restart();
|
||||
}
|
||||
|
||||
static int get_last_log_info(struct error_info *info)
|
||||
{
|
||||
struct fault_log_info *pinfo = (struct fault_log_info *)kernel_log;
|
||||
int log_size = KERNEL_LOG_MAX_SIZE;
|
||||
unsigned int i = 0;
|
||||
struct fault_log_info *pinfo = (struct fault_log_info *)kernel_log;
|
||||
int log_size = KERNEL_LOG_MAX_SIZE;
|
||||
unsigned int i = 0;
|
||||
|
||||
if (unlikely(!info || !kernel_log))
|
||||
return -EINVAL;
|
||||
if (unlikely(!info || !kernel_log))
|
||||
return -EINVAL;
|
||||
|
||||
if (storage_lastword->get_log((void *)kernel_log, log_size) < 0) {
|
||||
bbox_print_err("Get last log from strorage failed!\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
if (storage_lastword->get_log((void *)kernel_log, log_size) < 0) {
|
||||
bbox_print_err("Get last log from strorage failed!\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
down(&kmsg_sem);
|
||||
if (!memcmp(pinfo->flag, LOG_FLAG, strlen(LOG_FLAG))) {
|
||||
memcpy(info, &pinfo->info, sizeof(*info));
|
||||
for (i = 0; i < strlen((*info).event); i++)
|
||||
(*info).event[i] = toupper((*info).event[i]);
|
||||
down(&kmsg_sem);
|
||||
if (!memcmp(pinfo->flag, LOG_FLAG, strlen(LOG_FLAG))) {
|
||||
memcpy_s(info, sizeof(*info), &pinfo->info, sizeof(*info));
|
||||
for (i = 0; i < strlen((*info).event); i++)
|
||||
(*info).event[i] = toupper((*info).event[i]);
|
||||
|
||||
if (strncmp((*info).module, "PSTORE", strlen("PSTORE")) == 0)
|
||||
memcpy((*info).module, MODULE_SYSTEM, sizeof((*info).module));
|
||||
if (strncmp((*info).module, "PSTORE", strlen("PSTORE")) == 0)
|
||||
memcpy_s((*info).module, sizeof((*info).module), MODULE_SYSTEM, sizeof((*info).module));
|
||||
|
||||
up(&kmsg_sem);
|
||||
return 0;
|
||||
}
|
||||
up(&kmsg_sem);
|
||||
bbox_print_info("There's no valid fault log!\n");
|
||||
up(&kmsg_sem);
|
||||
return 0;
|
||||
}
|
||||
up(&kmsg_sem);
|
||||
bbox_print_info("There's no valid fault log!\n");
|
||||
|
||||
return -ENOMSG;
|
||||
return -ENOMSG;
|
||||
}
|
||||
|
||||
static int save_last_log(const char *log_dir, struct error_info *info)
|
||||
{
|
||||
int ret = -1;
|
||||
int ret = -1;
|
||||
|
||||
if (unlikely(!log_dir || !info)) {
|
||||
bbox_print_err("log_dir: %p, info: %p!\n", log_dir, info);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (unlikely(!log_dir || !info)) {
|
||||
bbox_print_err("log_dir: %p, info: %p!\n", log_dir, info);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = save_kmsg_from_buffer(log_dir, KERNEL_LOG_NAME, 1);
|
||||
bbox_print_info("save last fault log %s!\n",
|
||||
ret ? "failed" : "successfully");
|
||||
ret = save_kmsg_from_buffer(log_dir, KERNEL_LOG_NAME, 1);
|
||||
bbox_print_info("save last fault log %s!\n",
|
||||
ret ? "failed" : "successfully");
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bbox_reboot_notify(struct notifier_block *nb,
|
||||
unsigned long code, void *unused)
|
||||
unsigned long code, void *unused)
|
||||
{
|
||||
char error_desc[ERROR_DESC_MAX_LEN];
|
||||
char error_desc[ERROR_DESC_MAX_LEN];
|
||||
|
||||
/* notify blackbox to do dump */
|
||||
memset(error_desc, 0, sizeof(error_desc));
|
||||
dump_stacktrace(error_desc, sizeof(error_desc), false);
|
||||
kmsg_dump(KMSG_DUMP_UNDEF);
|
||||
/* notify blackbox to do dump */
|
||||
memset_s(error_desc, sizeof(error_desc), 0, sizeof(error_desc));
|
||||
dump_stacktrace(error_desc, sizeof(error_desc), false);
|
||||
kmsg_dump(KMSG_DUMP_UNDEF);
|
||||
|
||||
switch (code) {
|
||||
case SYS_RESTART:
|
||||
bbox_notify_error(EVENT_SYSREBOOT, MODULE_SYSTEM, error_desc, 1);
|
||||
break;
|
||||
case SYS_POWER_OFF:
|
||||
bbox_notify_error(EVENT_POWEROFF, MODULE_SYSTEM, error_desc, 0);
|
||||
break;
|
||||
default:
|
||||
bbox_print_err("Invalid event code: %lu!\n", code);
|
||||
break;
|
||||
}
|
||||
switch (code) {
|
||||
case SYS_RESTART:
|
||||
bbox_notify_error(EVENT_SYSREBOOT, MODULE_SYSTEM, error_desc, 1);
|
||||
break;
|
||||
case SYS_POWER_OFF:
|
||||
bbox_notify_error(EVENT_POWEROFF, MODULE_SYSTEM, error_desc, 0);
|
||||
break;
|
||||
default:
|
||||
bbox_print_err("Invalid event code: %lu!\n", code);
|
||||
break;
|
||||
}
|
||||
|
||||
return NOTIFY_DONE;
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static int bbox_task_panic(struct notifier_block *this,
|
||||
unsigned long event, void *ptr)
|
||||
unsigned long event, void *ptr)
|
||||
{
|
||||
char error_desc[ERROR_DESC_MAX_LEN];
|
||||
char error_desc[ERROR_DESC_MAX_LEN];
|
||||
|
||||
/* notify blackbox to do dump */
|
||||
kmsg_dump(KMSG_DUMP_PANIC);
|
||||
memset(error_desc, 0, sizeof(error_desc));
|
||||
bbox_notify_error(EVENT_PANIC, MODULE_SYSTEM, error_desc, 1);
|
||||
/* notify blackbox to do dump */
|
||||
kmsg_dump(KMSG_DUMP_PANIC);
|
||||
memset(error_desc, 0, sizeof(error_desc));
|
||||
bbox_notify_error(EVENT_PANIC, MODULE_SYSTEM, error_desc, 1);
|
||||
|
||||
return NOTIFY_DONE;
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static int __init blackbox_init(void)
|
||||
{
|
||||
int ret = -1;
|
||||
struct kmsg_dumper *dumper = NULL;
|
||||
struct module_ops ops = {
|
||||
.module = MODULE_SYSTEM,
|
||||
.dump = dump,
|
||||
.reset = reset,
|
||||
.get_last_log_info = get_last_log_info,
|
||||
.save_last_log = save_last_log,
|
||||
};
|
||||
int ret = -1;
|
||||
struct kmsg_dumper *dumper = NULL;
|
||||
struct module_ops ops = {
|
||||
.module = MODULE_SYSTEM,
|
||||
.dump = dump,
|
||||
.reset = reset,
|
||||
.get_last_log_info = get_last_log_info,
|
||||
.save_last_log = save_last_log,
|
||||
};
|
||||
|
||||
if (bbox_register_module_ops(&ops) != 0) {
|
||||
bbox_print_err("bbox_register_module_ops failed!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (bbox_register_module_ops(&ops) != 0) {
|
||||
bbox_print_err("bbox_register_module_ops failed!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* allocate buffer for kmsg */
|
||||
kernel_log = kmalloc(KERNEL_LOG_MAX_SIZE, GFP_KERNEL);
|
||||
if (!kernel_log)
|
||||
goto __err;
|
||||
memset(kernel_log, 0, KERNEL_LOG_MAX_SIZE);
|
||||
/* allocate buffer for kmsg */
|
||||
kernel_log = kmalloc(KERNEL_LOG_MAX_SIZE, GFP_KERNEL);
|
||||
if (!kernel_log)
|
||||
goto __err;
|
||||
memset(kernel_log, 0, KERNEL_LOG_MAX_SIZE);
|
||||
|
||||
/* register kdumper */
|
||||
dumper = kmalloc(sizeof(*dumper), GFP_KERNEL);
|
||||
if (!dumper)
|
||||
goto __err;
|
||||
/* register kdumper */
|
||||
dumper = kmalloc(sizeof(*dumper), GFP_KERNEL);
|
||||
if (!dumper)
|
||||
goto __err;
|
||||
|
||||
memset(dumper, 0, sizeof(*dumper));
|
||||
dumper->max_reason = KMSG_DUMP_OOPS;
|
||||
dumper->dump = storage_lastword->blackbox_dump;
|
||||
ret = kmsg_dump_register(dumper);
|
||||
if (ret != 0) {
|
||||
bbox_print_err("kmsg_dump_register failed!\n");
|
||||
goto __err;
|
||||
}
|
||||
atomic_notifier_chain_register(&panic_notifier_list, &bbox_panic_block);
|
||||
memset(dumper, 0, sizeof(*dumper));
|
||||
dumper->max_reason = KMSG_DUMP_OOPS;
|
||||
dumper->dump = storage_lastword->blackbox_dump;
|
||||
ret = kmsg_dump_register(dumper);
|
||||
if (ret != 0) {
|
||||
bbox_print_err("kmsg_dump_register failed!\n");
|
||||
goto __err;
|
||||
}
|
||||
atomic_notifier_chain_register(&panic_notifier_list, &bbox_panic_block);
|
||||
|
||||
register_reboot_notifier(&bbox_reboot_nb);
|
||||
return 0;
|
||||
register_reboot_notifier(&bbox_reboot_nb);
|
||||
return 0;
|
||||
|
||||
__err:
|
||||
kfree(kernel_log);
|
||||
kernel_log = NULL;
|
||||
kfree(kernel_log);
|
||||
kernel_log = NULL;
|
||||
|
||||
if (dumper) {
|
||||
kfree(dumper);
|
||||
dumper = NULL;
|
||||
}
|
||||
if (dumper) {
|
||||
kfree(dumper);
|
||||
dumper = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
postcore_initcall(blackbox_init);
|
||||
|
||||
@@ -63,8 +63,8 @@ static void dump_stacktrace(char *pbuf, size_t buf_size, bool is_panic)
|
||||
if (unlikely(!pbuf || !buf_size))
|
||||
return;
|
||||
|
||||
memset(pbuf, 0, buf_size);
|
||||
memset(tmp_buf, 0, sizeof(tmp_buf));
|
||||
memset_s(pbuf, buf_size, 0, buf_size);
|
||||
memset_s(tmp_buf, sizeof(tmp_buf), 0, sizeof(tmp_buf));
|
||||
nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
|
||||
com_len = scnprintf(pbuf, buf_size, "Comm:%s,CPU:%d,Stack:",
|
||||
current->comm, raw_smp_processor_id());
|
||||
@@ -79,13 +79,22 @@ static void dump_stacktrace(char *pbuf, size_t buf_size, bool is_panic)
|
||||
if (strncmp(tmp_buf, "panic", strlen("panic")) == 0)
|
||||
find_panic = true;
|
||||
else
|
||||
(void)memset(tmp_buf, 0, sizeof(tmp_buf));
|
||||
(void)memset_s(tmp_buf, sizeof(tmp_buf), 0, sizeof(tmp_buf));
|
||||
}
|
||||
}
|
||||
if (com_len >= buf_size)
|
||||
return;
|
||||
stack_len = min(buf_size - com_len, strlen(tmp_buf));
|
||||
memcpy(pbuf + com_len, tmp_buf, stack_len);
|
||||
|
||||
errno_t err = EOK;
|
||||
if (pbuf + com_len == NULL || stack_len == 1) {
|
||||
return;
|
||||
}
|
||||
err = memcpy_s(pbuf + com_len, stack_len, tmp_buf, stack_len);
|
||||
if (err != EOK) {
|
||||
return;
|
||||
}
|
||||
|
||||
*(pbuf + buf_size - 1) = '\0';
|
||||
}
|
||||
|
||||
@@ -101,7 +110,7 @@ static int save_kmsg_from_buffer(const char *log_dir,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
memset_s(path, sizeof(path), 0, sizeof(path));
|
||||
(void)scnprintf(path, sizeof(path) - 1, "%s/%s", log_dir, file_name);
|
||||
down(&kmsg_sem);
|
||||
if (kernel_log) {
|
||||
@@ -110,7 +119,7 @@ static int save_kmsg_from_buffer(const char *log_dir,
|
||||
min(KERNEL_LOG_MAX_SIZE - sizeof(*pinfo),
|
||||
(size_t)pinfo->len), 0);
|
||||
if (clean_buf)
|
||||
memset(kernel_log, 0, KERNEL_LOG_MAX_SIZE);
|
||||
memset_s(kernel_log, KERNEL_LOG_MAX_SIZE, 0, KERNEL_LOG_MAX_SIZE);
|
||||
} else {
|
||||
bbox_print_err("kernel_log: %p!\n", kernel_log);
|
||||
}
|
||||
@@ -137,8 +146,8 @@ static void dump(const char *log_dir, struct error_info *info)
|
||||
}
|
||||
|
||||
if (kernel_log) {
|
||||
memcpy(pinfo->flag, LOG_FLAG, strlen(LOG_FLAG));
|
||||
memcpy(&pinfo->info, info, sizeof(*info));
|
||||
memcpy_s(pinfo->flag, strlen(LOG_FLAG), LOG_FLAG, strlen(LOG_FLAG));
|
||||
memcpy_s(&pinfo->info, sizeof(*info), info, sizeof(*info));
|
||||
|
||||
#if __BITS_PER_LONG == 64
|
||||
__flush_dcache_area(kernel_log, KERNEL_LOG_MAX_SIZE);
|
||||
@@ -183,7 +192,7 @@ static int get_last_log_info(struct error_info *info)
|
||||
|
||||
down(&kmsg_sem);
|
||||
if (!memcmp(pinfo->flag, LOG_FLAG, strlen(LOG_FLAG))) {
|
||||
memcpy(info, &pinfo->info, sizeof(*info));
|
||||
memcpy_s(info, sizeof(*info), &pinfo->info, sizeof(*info));
|
||||
|
||||
up(&kmsg_sem);
|
||||
return 0;
|
||||
@@ -216,7 +225,7 @@ static int bbox_reboot_notify(struct notifier_block *nb,
|
||||
char error_desc[ERROR_DESC_MAX_LEN];
|
||||
|
||||
/* notify blackbox to do dump */
|
||||
memset(error_desc, 0, sizeof(error_desc));
|
||||
memset_s(error_desc, sizeof(error_desc), 0, sizeof(error_desc));
|
||||
dump_stacktrace(error_desc, sizeof(error_desc), false);
|
||||
kmsg_dump(KMSG_DUMP_UNDEF);
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ static void __log_abort_or_abnormal_wake(bool abort, const char *fmt, va_list ar
|
||||
wakeup_reason = RESUME_ABNORMAL;
|
||||
}
|
||||
|
||||
vsnprintf(non_irq_wake_reason, MAX_SUSPEND_ABORT_LEN, fmt, args);
|
||||
vsnprintf_s(non_irq_wake_reason, sizeof(non_irq_wake_reason), MAX_SUSPEND_ABORT_LEN, fmt, args);
|
||||
|
||||
spin_unlock_irqrestore(&wakeup_reason_lock, flags);
|
||||
}
|
||||
@@ -340,6 +340,7 @@ static ssize_t last_suspend_time_show(struct kobject *kobj,
|
||||
struct timespec64 sleep_time;
|
||||
struct timespec64 total_time;
|
||||
struct timespec64 suspend_resume_time;
|
||||
size_t stack_len = 100;
|
||||
|
||||
/*
|
||||
* total_time is calculated from monotonic bootoffsets because
|
||||
@@ -358,11 +359,9 @@ static ssize_t last_suspend_time_show(struct kobject *kobj,
|
||||
sleep_time = timespec64_sub(total_time, suspend_resume_time);
|
||||
|
||||
/* Export suspend_resume_time and sleep_time in pair here. */
|
||||
return sprintf(buf, "%llu.%09lu %llu.%09lu\n",
|
||||
(unsigned long long)suspend_resume_time.tv_sec,
|
||||
suspend_resume_time.tv_nsec,
|
||||
(unsigned long long)sleep_time.tv_sec,
|
||||
sleep_time.tv_nsec);
|
||||
return sprintf_s(buf, stack_len, "%llu.%09lu %llu.%09lu\n",
|
||||
(unsigned long long)suspend_resume_time.tv_sec, suspend_resume_time.tv_nsec,
|
||||
(unsigned long long)sleep_time.tv_sec, sleep_time.tv_nsec);
|
||||
}
|
||||
|
||||
static struct kobj_attribute resume_reason = __ATTR_RO(last_resume_reason);
|
||||
|
||||
@@ -250,7 +250,7 @@ void sha1_update(sha1_context *ctx, const unsigned char *input,
|
||||
ctx->total[1]++;
|
||||
|
||||
if (left && ilen >= fill) {
|
||||
memcpy ((void *) (ctx->buffer + left), (void *) input, fill);
|
||||
memcpy_s((void *) (ctx->buffer + left), fill, (void *) input, fill);
|
||||
sha1_process (ctx, ctx->buffer);
|
||||
input += fill;
|
||||
ilen -= fill;
|
||||
@@ -264,7 +264,7 @@ void sha1_update(sha1_context *ctx, const unsigned char *input,
|
||||
}
|
||||
|
||||
if (ilen > 0) {
|
||||
memcpy ((void *) (ctx->buffer + left), (void *) input, ilen);
|
||||
memcpy_s((void *) (ctx->buffer + left), ilen, (void *) input, ilen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ void sha256_update(sha256_context *ctx, const uint8_t *input, uint32_t length)
|
||||
ctx->total[1]++;
|
||||
|
||||
if (left && length >= fill) {
|
||||
memcpy((void *) (ctx->buffer + left), (void *) input, fill);
|
||||
memcpy_s((void *) (ctx->buffer + left), fill, (void *) input, fill);
|
||||
sha256_process(ctx, ctx->buffer);
|
||||
length -= fill;
|
||||
input += fill;
|
||||
@@ -515,7 +515,7 @@ void sha256_update(sha256_context *ctx, const uint8_t *input, uint32_t length)
|
||||
}
|
||||
|
||||
if (length)
|
||||
memcpy((void *) (ctx->buffer + left), (void *) input, length);
|
||||
memcpy_s((void *) (ctx->buffer + left), length, (void *) input, length);
|
||||
}
|
||||
|
||||
static uint8_t sha256_padding[64] = {
|
||||
@@ -775,7 +775,7 @@ static bool write_data(int offset_block, void *data, size_t len)
|
||||
int left = len % BLOCK_SIZE;
|
||||
if (left) {
|
||||
char buf[BLOCK_SIZE] = "\0";
|
||||
memcpy(buf, data + blocks * BLOCK_SIZE, left);
|
||||
(void)memcpy_s(buf, sizeof(buf), data + blocks * BLOCK_SIZE, left);
|
||||
if (!StorageWriteLba(offset_block + blocks, buf, 1))
|
||||
goto end;
|
||||
}
|
||||
@@ -832,7 +832,9 @@ static bool load_content(resource_content *content)
|
||||
if (content->load_addr)
|
||||
return true;
|
||||
int blocks = fix_blocks(content->content_size);
|
||||
content->load_addr = malloc(blocks * BLOCK_SIZE);
|
||||
if (blocks > 0) {
|
||||
content->load_addr = malloc(blocks * BLOCK_SIZE);
|
||||
}
|
||||
if (!content->load_addr)
|
||||
return false;
|
||||
if (!StorageReadLba(get_ptn_offset() + content->content_offset,
|
||||
@@ -865,7 +867,7 @@ static bool get_entry(const char *file_path, index_tbl_entry *entry)
|
||||
LOGE("Failed to read header!");
|
||||
goto end;
|
||||
}
|
||||
memcpy(&header, buf, sizeof(header));
|
||||
memcpy_s(&header, sizeof(header), buf, sizeof(header));
|
||||
|
||||
if (memcmp(header.magic, RESOURCE_PTN_HDR_MAGIC, sizeof(header.magic))) {
|
||||
LOGE("Not a resource image(%s)!", image_path);
|
||||
@@ -892,7 +894,7 @@ static bool get_entry(const char *file_path, index_tbl_entry *entry)
|
||||
LOGE("Failed to read index entry:%d!", i);
|
||||
goto end;
|
||||
}
|
||||
memcpy(entry, buf, sizeof(*entry));
|
||||
memcpy_s(entry, sizeof(*entry), buf, sizeof(*entry));
|
||||
|
||||
if (memcmp(entry->tag, INDEX_TBL_ENTR_TAG, sizeof(entry->tag))) {
|
||||
LOGE("Something wrong with index entry:%d!", i);
|
||||
@@ -940,7 +942,7 @@ static int load_file(const char *file_path, int offset_block, int blocks)
|
||||
}
|
||||
bool ret = false;
|
||||
resource_content content;
|
||||
snprintf(content.path, sizeof(content.path), "%s", file_path);
|
||||
(void)snprintf_s(content.path, sizeof(content.path), sizeof(content.path), "%s", file_path);
|
||||
content.load_addr = 0;
|
||||
if (!get_content(&content)) {
|
||||
goto end;
|
||||
@@ -949,7 +951,7 @@ static int load_file(const char *file_path, int offset_block, int blocks)
|
||||
if (!load_content(&content)) {
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
} else if (blocks > 0) {
|
||||
void *data = malloc(blocks * BLOCK_SIZE);
|
||||
if (!data)
|
||||
goto end;
|
||||
@@ -968,7 +970,7 @@ end:
|
||||
|
||||
static bool parse_level_conf(const char *arg, anim_level_conf *level_conf)
|
||||
{
|
||||
memset(level_conf, 0, sizeof(anim_level_conf));
|
||||
memset_s(level_conf, sizeof(anim_level_conf), 0, sizeof(anim_level_conf));
|
||||
char *buf = NULL;
|
||||
buf = strstr(arg, OPT_CHARGE_ANIM_LEVEL_CONF);
|
||||
if (buf) {
|
||||
@@ -993,7 +995,7 @@ static bool parse_level_conf(const char *arg, anim_level_conf *level_conf)
|
||||
}
|
||||
buf = strstr(arg, OPT_CHARGE_ANIM_LEVEL_PFX);
|
||||
if (buf) {
|
||||
snprintf(level_conf->prefix, sizeof(level_conf->prefix), "%s",
|
||||
snprintf_s(level_conf->prefix, sizeof(level_conf->prefix), sizeof(level_conf->prefix), "%s",
|
||||
buf + strlen(OPT_CHARGE_ANIM_LEVEL_PFX));
|
||||
} else {
|
||||
LOGE("Not found:%s", OPT_CHARGE_ANIM_LEVEL_PFX);
|
||||
@@ -1016,7 +1018,7 @@ static int test_charge(int argc, char **argv)
|
||||
}
|
||||
|
||||
resource_content content;
|
||||
snprintf(content.path, sizeof(content.path), "%s", desc);
|
||||
(void)snprintf_s(content.path, sizeof(content.path), sizeof(content.path), "%s", desc);
|
||||
content.load_addr = 0;
|
||||
if (!get_content(&content)) {
|
||||
goto end;
|
||||
@@ -1116,8 +1118,8 @@ static int test_charge(int argc, char **argv)
|
||||
}
|
||||
if (level_confs[j].max_level > level_confs[i].max_level) {
|
||||
anim_level_conf conf = level_confs[i];
|
||||
memmove(level_confs + j + 1, level_confs + j,
|
||||
(i - j) * sizeof(anim_level_conf));
|
||||
(void)memmove_s(level_confs + j + 1, i * sizeof(anim_level_conf), level_confs + j,
|
||||
(i - j) * sizeof(anim_level_conf));
|
||||
level_confs[j] = conf;
|
||||
}
|
||||
}
|
||||
@@ -1207,9 +1209,9 @@ int main(int argc, char **argv)
|
||||
} else if (!strcmp(OPT_TEST_CHARGE, arg)) {
|
||||
action = ACTION_TEST_CHARGE;
|
||||
} else if (!memcmp(OPT_IMAGE, arg, strlen(OPT_IMAGE))) {
|
||||
snprintf(image_path, sizeof(image_path), "%s", arg + strlen(OPT_IMAGE));
|
||||
(void)snprintf_s(image_path, sizeof(image_path), sizeof(image_path), "%s", arg + strlen(OPT_IMAGE));
|
||||
} else if (!memcmp(OPT_ROOT, arg, strlen(OPT_ROOT))) {
|
||||
snprintf(root_path, sizeof(root_path), "%s", arg + strlen(OPT_ROOT));
|
||||
(void)snprintf_s(root_path, sizeof(root_path), sizeof(root_path), "%s", arg + strlen(OPT_ROOT));
|
||||
} else {
|
||||
LOGE("Unknown opt:%s", arg);
|
||||
usage();
|
||||
@@ -1218,7 +1220,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!image_path[0]) {
|
||||
snprintf(image_path, sizeof(image_path), "%s", DEFAULT_IMAGE_PATH);
|
||||
snprintf_s(image_path, sizeof(image_path), sizeof(image_path), "%s", DEFAULT_IMAGE_PATH);
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
@@ -1254,7 +1256,15 @@ static bool mkdirs(char *path)
|
||||
char buf[MAX_INDEX_ENTRY_PATH_LEN];
|
||||
bool ret = true;
|
||||
while ((pos = memchr(tmp, '/', strlen(tmp)))) {
|
||||
strcpy(buf, path);
|
||||
errno_t err = EOK;
|
||||
if (buf == NULL || sizeof(buf) == 1) {
|
||||
return;
|
||||
}
|
||||
err = strcpy_s(buf, sizeof(buf), path);
|
||||
if (err != EOK) {
|
||||
return;
|
||||
}
|
||||
|
||||
buf[pos - path] = '\0';
|
||||
tmp = pos + 1;
|
||||
LOGD("mkdir:%s", buf);
|
||||
@@ -1267,10 +1277,8 @@ static bool mkdirs(char *path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool dump_file(FILE *file, const char *unpack_dir,
|
||||
index_tbl_entry entry)
|
||||
static bool dump_file(FILE *file, const char *unpack_dir, index_tbl_entry entry)
|
||||
{
|
||||
LOGD("try to dump entry:%s", entry.path);
|
||||
bool ret = false;
|
||||
FILE *out_file = NULL;
|
||||
long int pos = 0;
|
||||
@@ -1281,17 +1289,24 @@ static bool dump_file(FILE *file, const char *unpack_dir,
|
||||
}
|
||||
|
||||
pos = ftell(file);
|
||||
snprintf(path, sizeof(path), "%s/%s", unpack_dir, entry.path);
|
||||
|
||||
errno_t err = EOK;
|
||||
if (path == NULL || sizeof(path) == 1) {
|
||||
return;
|
||||
}
|
||||
err = snprintf_s(path, sizeof(path), sizeof(path), "%s/%s", unpack_dir, entry.path);
|
||||
if (err != EOK) {
|
||||
return;
|
||||
}
|
||||
|
||||
mkdirs(path);
|
||||
out_file = fopen(path, "wb");
|
||||
if (!out_file) {
|
||||
LOGE("Failed to create:%s", path);
|
||||
goto end;
|
||||
}
|
||||
long int offset = entry.content_offset * BLOCK_SIZE;
|
||||
fseek(file, offset, SEEK_SET);
|
||||
if (offset != ftell(file)) {
|
||||
LOGE("Failed to read content:%s", entry.path);
|
||||
goto end;
|
||||
}
|
||||
char buf[BLOCK_SIZE];
|
||||
@@ -1326,7 +1341,15 @@ static int unpack_image(const char *dir)
|
||||
char unpack_dir[MAX_INDEX_ENTRY_PATH_LEN];
|
||||
if (just_print)
|
||||
dir = ".";
|
||||
snprintf(unpack_dir, sizeof(unpack_dir), "%s", dir);
|
||||
|
||||
errno_t err = EOK;
|
||||
if (unpack_dir == NULL || sizeof(unpack_dir) == 1) {
|
||||
return;
|
||||
}
|
||||
err = snprintf_s(unpack_dir, sizeof(unpack_dir), sizeof(unpack_dir), "%s", dir);
|
||||
if (err != EOK) {
|
||||
return;
|
||||
}
|
||||
if (!strlen(unpack_dir)) {
|
||||
goto end;
|
||||
} else if (unpack_dir[strlen(unpack_dir) - 1] == '/') {
|
||||
@@ -1344,7 +1367,7 @@ static int unpack_image(const char *dir)
|
||||
LOGE("Failed to read header!");
|
||||
goto end;
|
||||
}
|
||||
memcpy(&header, buf, sizeof(header));
|
||||
memcpy_s(&header, sizeof(header), buf, sizeof(header));
|
||||
|
||||
if (memcmp(header.magic, RESOURCE_PTN_HDR_MAGIC, sizeof(header.magic))) {
|
||||
LOGE("Not a resource image(%s)!", image_path);
|
||||
@@ -1378,7 +1401,7 @@ static int unpack_image(const char *dir)
|
||||
LOGE("Failed to read index entry:%d!", i);
|
||||
goto end;
|
||||
}
|
||||
memcpy(&entry, buf, sizeof(entry));
|
||||
memcpy_s(&entry, sizeof(entry), buf, sizeof(entry));
|
||||
|
||||
if (memcmp(entry.tag, INDEX_TBL_ENTR_TAG, sizeof(entry.tag))) {
|
||||
LOGE("Something wrong with index entry:%d!", i);
|
||||
@@ -1466,7 +1489,7 @@ end:
|
||||
static bool write_header(const int file_num)
|
||||
{
|
||||
LOGD("try to write header...");
|
||||
memcpy(header.magic, RESOURCE_PTN_HDR_MAGIC, sizeof(header.magic));
|
||||
memcpy_s(header.magic, sizeof(header.magic), RESOURCE_PTN_HDR_MAGIC, sizeof(header.magic));
|
||||
header.resource_ptn_version = RESOURCE_PTN_VERSION;
|
||||
header.index_tbl_version = INDEX_TBL_VERSION;
|
||||
header.header_size = RESOURCE_PTN_HDR_SIZE;
|
||||
@@ -1491,7 +1514,7 @@ static bool write_index_tbl(const int file_num, const char **files)
|
||||
char hash[20]; /* sha1 */
|
||||
int i;
|
||||
LOGE("write_index_tbl %d\n",file_num);
|
||||
memcpy(entry.tag, INDEX_TBL_ENTR_TAG, sizeof(entry.tag));
|
||||
memcpy_s(entry.tag, sizeof(entry.tag), INDEX_TBL_ENTR_TAG, sizeof(entry.tag));
|
||||
for (i = 0; i < file_num; i++) {
|
||||
size_t file_size = get_file_size(files[i]);
|
||||
if (file_size < 0)
|
||||
@@ -1502,14 +1525,14 @@ static bool write_index_tbl(const int file_num, const char **files)
|
||||
if (write_file(offset, files[i], hash, sizeof(hash)) < 0)
|
||||
goto end;
|
||||
|
||||
memcpy(entry.hash, hash, sizeof(hash));
|
||||
memcpy_s(entry.hash, sizeof(entry.hash), hash, sizeof(hash));
|
||||
entry.hash_size = sizeof(hash);
|
||||
|
||||
LOGE("try to write index entry(%s)...", files[i]);
|
||||
|
||||
/* switch for le. */
|
||||
fix_entry(&entry);
|
||||
memset(entry.path, 0, sizeof(entry.path));
|
||||
memset_s(entry.path, sizeof(entry.path), 0, sizeof(entry.path));
|
||||
const char *path = files[i];
|
||||
if (root_path[0]) {
|
||||
if (!strncmp(path, root_path, strlen(root_path))) {
|
||||
@@ -1527,7 +1550,7 @@ static bool write_index_tbl(const int file_num, const char **files)
|
||||
foundFdt = true;
|
||||
}
|
||||
}
|
||||
snprintf(entry.path, sizeof(entry.path), "%s", path);
|
||||
(void)snprintf_s(entry.path, sizeof(entry.path), sizeof(entry.path), "%s", path);
|
||||
offset += fix_blocks(file_size);
|
||||
if (!write_data(header.header_size + i * header.tbl_entry_size, &entry,
|
||||
sizeof(entry)))
|
||||
|
||||
@@ -245,7 +245,7 @@ static int mdais_read_prop_array(struct device_node *node,
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
memset(array, 0, sizeof(*array) * num);
|
||||
memset_s(array, sizeof(*array) * num, 0, sizeof(*array) * num);
|
||||
if (of_property_read_bool(node, propname)) {
|
||||
ret = of_property_read_u32_array(node, propname, array, num);
|
||||
if (ret) {
|
||||
|
||||
@@ -402,7 +402,7 @@ static int dmaengine_mpcm_hw_params(struct snd_pcm_substream *substream,
|
||||
num = pcm->mdais->num_dais;
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
memset(&slave_config, 0, sizeof(slave_config));
|
||||
memset_s(&slave_config, sizeof(slave_config), 0, sizeof(slave_config));
|
||||
ret = snd_hwparams_to_dma_slave_config(substream, params,
|
||||
&slave_config);
|
||||
if (ret) {
|
||||
@@ -467,7 +467,7 @@ static int dmaengine_mpcm_set_runtime_hwparams(struct snd_pcm_substream *substre
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(&hw, 0, sizeof(hw));
|
||||
memset_s(&hw, sizeof(hw), 0, sizeof(hw));
|
||||
hw.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
|
||||
SNDRV_PCM_INFO_INTERLEAVED;
|
||||
hw.periods_min = 2;
|
||||
|
||||
@@ -299,7 +299,7 @@ snd_pcm_uframes_t snd_pcm_vad_avail(struct snd_pcm_substream *substream)
|
||||
}
|
||||
|
||||
vframes = samples_to_bytes(runtime, vad->channels);
|
||||
if (vframes) {
|
||||
if (vframes != 0) {
|
||||
vframes = vbuf->size / vframes;
|
||||
}
|
||||
if (!vframes) {
|
||||
@@ -520,7 +520,7 @@ snd_pcm_sframes_t snd_pcm_vad_memcpy(struct snd_pcm_substream *substream,
|
||||
padding_sz = frame_sz - vframe_sz;
|
||||
vbytes = vframe_sz * avail;
|
||||
|
||||
memset(buf, 0x0, bytes);
|
||||
memset_s(buf, bytes, 0x0, bytes);
|
||||
if (!vbuf->loop) {
|
||||
vad_memcpy_fromio(buf, vbuf->pos, vbytes,
|
||||
vframe_sz, padding_sz);
|
||||
@@ -535,7 +535,7 @@ snd_pcm_sframes_t snd_pcm_vad_memcpy(struct snd_pcm_substream *substream,
|
||||
int part2 = vbytes - part1;
|
||||
int offset = part1;
|
||||
|
||||
if (padding_sz) {
|
||||
if (padding_sz&&vframe_sz != 0) {
|
||||
offset = part1 / vframe_sz * frame_sz;
|
||||
}
|
||||
vad_memcpy_fromio(buf, vbuf->pos, part1,
|
||||
|
||||
Reference in New Issue
Block a user