mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
Use lib_get_pathbuffer instead of stack variables
Summary: Modified the usage logic, mainly introduced lib_get_pathbuffer and lib_put_pathbuffer Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
+10
-2
@@ -47,6 +47,7 @@
|
||||
#include <nuttx/input/aw86225.h>
|
||||
#include <nuttx/input/ff.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/lib/lib.h>
|
||||
|
||||
#include "aw86225_reg.h"
|
||||
#include "aw86225_internal.h"
|
||||
@@ -369,14 +370,21 @@ static int aw86225_i2c_write_bits(FAR struct aw86225 *aw86225,
|
||||
static int aw86225_request_firmware(FAR struct aw86225_firmware *fw,
|
||||
FAR const char *filename)
|
||||
{
|
||||
char file_path[PATH_MAX];
|
||||
FAR char *file_path;
|
||||
struct file file;
|
||||
size_t file_size;
|
||||
int ret;
|
||||
|
||||
snprintf(file_path, sizeof(file_path), "%s/%s", CONFIG_FF_RTP_FILE_PATH,
|
||||
file_path = lib_get_pathbuffer();
|
||||
if (file_path == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
snprintf(file_path, PATH_MAX, "%s/%s", CONFIG_FF_RTP_FILE_PATH,
|
||||
filename);
|
||||
ret = file_open(&file, file_path, O_RDONLY);
|
||||
lib_put_pathbuffer(file_path);
|
||||
if (ret < 0)
|
||||
{
|
||||
ierr("open file failed");
|
||||
|
||||
Reference in New Issue
Block a user