This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 12fda1da1c boards: Replace open/pread with file_open/file_pread
12fda1da1c is described below

commit 12fda1da1c5dba2d5c2eb6c1ab154519b094a183
Author: Xiang Xiao <xiaoxi...@xiaomi.com>
AuthorDate: Sat Apr 1 20:04:02 2023 +0800

    boards: Replace open/pread with file_open/file_pread
    
    Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com>
---
 boards/arm/imxrt/imxrt1064-evk/src/imxrt_boot_image.c   | 13 +++++++------
 boards/arm/samv7/common/src/sam_boot_image.c            | 13 +++++++------
 boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c | 13 +++++++------
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/boards/arm/imxrt/imxrt1064-evk/src/imxrt_boot_image.c 
b/boards/arm/imxrt/imxrt1064-evk/src/imxrt_boot_image.c
index ccfa93ffff..830d1695bd 100644
--- a/boards/arm/imxrt/imxrt1064-evk/src/imxrt_boot_image.c
+++ b/boards/arm/imxrt/imxrt1064-evk/src/imxrt_boot_image.c
@@ -137,17 +137,18 @@ static void systick_disable(void)
 int board_boot_image(const char *path, uint32_t hdr_size)
 {
   static struct arm_vector_table vt;
-  int fd;
+  struct file file;
   ssize_t bytes;
+  int ret;
 
-  fd = open(path, O_RDONLY | O_CLOEXEC);
-  if (fd < 0)
+  ret = file_open(&file, path, O_RDONLY | O_CLOEXEC);
+  if (ret < 0)
     {
-      syslog(LOG_ERR, "Failed to open %s with: %d", path, fd);
-      return fd;
+      syslog(LOG_ERR, "Failed to open %s with: %d", path, ret);
+      return ret;
     }
 
-  bytes = pread(fd, &vt, sizeof(vt), hdr_size);
+  bytes = file_pread(&file, &vt, sizeof(vt), hdr_size);
   if (bytes != sizeof(vt))
     {
       syslog(LOG_ERR, "Failed to read ARM vector table: %d", bytes);
diff --git a/boards/arm/samv7/common/src/sam_boot_image.c 
b/boards/arm/samv7/common/src/sam_boot_image.c
index 15678ce531..b3bf55cb58 100644
--- a/boards/arm/samv7/common/src/sam_boot_image.c
+++ b/boards/arm/samv7/common/src/sam_boot_image.c
@@ -139,17 +139,18 @@ static void systick_disable(void)
 int board_boot_image(const char *path, uint32_t hdr_size)
 {
   static struct arm_vector_table vt;
-  int fd;
+  struct file file;
   ssize_t bytes;
+  int ret;
 
-  fd = open(path, O_RDONLY | O_CLOEXEC);
-  if (fd < 0)
+  ret = file_open(&file, path, O_RDONLY | O_CLOEXEC);
+  if (ret < 0)
     {
-      syslog(LOG_ERR, "Failed to open %s with: %d", path, fd);
-      return fd;
+      syslog(LOG_ERR, "Failed to open %s with: %d", path, ret);
+      return ret;
     }
 
-  bytes = pread(fd, &vt, sizeof(vt), hdr_size);
+  bytes = file_pread(&file, &vt, sizeof(vt), hdr_size);
   if (bytes != sizeof(vt))
     {
       syslog(LOG_ERR, "Failed to read ARM vector table: %d", bytes);
diff --git a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c 
b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c
index cd0edde5ad..f09e0847c6 100644
--- a/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c
+++ b/boards/arm/stm32h7/nucleo-h743zi/src/stm32_boot_image.c
@@ -137,17 +137,18 @@ static void systick_disable(void)
 int board_boot_image(const char *path, uint32_t hdr_size)
 {
   static struct arm_vector_table vt;
-  int fd;
+  struct file file;
   ssize_t bytes;
+  int ret;
 
-  fd = open(path, O_RDONLY | O_CLOEXEC);
-  if (fd < 0)
+  ret = file_open(&file, path, O_RDONLY | O_CLOEXEC);
+  if (ret < 0)
     {
-      syslog(LOG_ERR, "Failed to open %s with: %d", path, fd);
-      return fd;
+      syslog(LOG_ERR, "Failed to open %s with: %d", path, ret);
+      return ret;
     }
 
-  bytes = pread(fd, &vt, sizeof(vt), hdr_size);
+  bytes = file_pread(&file, &vt, sizeof(vt), hdr_size);
   if (bytes != sizeof(vt))
     {
       syslog(LOG_ERR, "Failed to read ARM vector table: %d", bytes);

Reply via email to