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

xiaoxiang 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 cdbf5c6ebe Fix compilation errors
cdbf5c6ebe is described below

commit cdbf5c6ebe43b597038854e4d0d5ceef2a93e0ac
Author: wangmingrong1 <[email protected]>
AuthorDate: Tue Nov 26 11:12:07 2024 +0800

    Fix compilation errors
    
    CC:  gcov.c gcov.c: In function 'gcov_stdout_dump':
    gcov.c:146:50: error: passing argument 3 of '__gcov_info_to_gcda' from 
incompatible pointer type [-Werror=incompatible-pointer-types]
      146 |       __gcov_info_to_gcda(info, stdout_filename, stdout_dump, NULL, 
&arg);
          |                                                  ^~~~~~~~~~~
          |                                                  |
          |                                                  void (*)(const 
void *, size_t,  void *) {aka void (*)(const void *, long unsigned int,  void 
*)}
    In file included from gcov.c:25:
    /mnt/vela/github/NX/nuttx/include/gcov.h:139:44: note: expected 'void 
(*)(const void *, unsigned int,  void *)' but argument is of type 'void 
(*)(const void *, size_t,  void *)' {aka 'void (*)(const void *, long unsigned 
int,  void *)'}
      139 |                                 FAR void (*dump)(FAR const void *,
          |                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      140 |                                                  unsigned int, FAR 
void *),
          |                                                  
~~~~~~~~~~~~~~~~~~~~~~~~~
    
    libgcc/gcov.c: In function 'gcov_process_path.constprop':
    libgcc/gcov.c:235:29: error: 'filename' may be used uninitialized 
[-Werror=maybe-uninitialized]
      235 |       tokens[token_count++] = filename;
          |       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
    libgcc/gcov.c:189:13: note: 'filename' was declared here
      189 |   FAR char *filename;
    
    Signed-off-by: wangmingrong1 <[email protected]>
---
 include/gcov.h                |  2 +-
 libs/libbuiltin/libgcc/gcov.c | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/include/gcov.h b/include/gcov.h
index 1faad7a9a8..3c6251b82c 100644
--- a/include/gcov.h
+++ b/include/gcov.h
@@ -137,7 +137,7 @@ extern void __gcov_info_to_gcda(FAR const struct gcov_info 
*info,
                                 FAR void (*filename)(FAR const char *,
                                                      FAR void *),
                                 FAR void (*dump)(FAR const void *,
-                                                 unsigned int, FAR void *),
+                                                 size_t, FAR void *),
                                 FAR void *(*allocate)(unsigned int,
                                                       FAR void *),
                                 FAR void *arg);
diff --git a/libs/libbuiltin/libgcc/gcov.c b/libs/libbuiltin/libgcc/gcov.c
index a98ae36cd8..eac1c3c539 100644
--- a/libs/libbuiltin/libgcc/gcov.c
+++ b/libs/libbuiltin/libgcc/gcov.c
@@ -205,6 +205,11 @@ static int gcov_process_path(FAR char *prefix, int strip,
 
   prefix_count = token_count;
   token = strtok(path, "/");
+  if (token == NULL)
+    {
+      return -EINVAL;
+    }
+
   while (token != NULL)
     {
       filename = token;
@@ -315,10 +320,23 @@ void __gcov_dump(void)
   FAR struct gcov_info *info;
   FAR const char *strip = getenv("GCOV_PREFIX_STRIP");
   FAR const char *prefix = getenv("GCOV_PREFIX");
-  FAR char *prefix2 = strdup(prefix);
   FAR char new_path[PATH_MAX];
+  FAR char *prefix2;
   int ret;
 
+  if (prefix == NULL)
+    {
+      syslog(LOG_ERR, "No path prefix specified");
+      return;
+    }
+
+  prefix2 = strdup(prefix);
+  if (prefix2 == NULL)
+    {
+      syslog(LOG_ERR, "gcov alloc failed!");
+      return;
+    }
+
   for (info = __gcov_info_start; info; info = info->next)
     {
       FAR char *filename;
@@ -401,7 +419,7 @@ void __gcov_filename_to_gcfn(FAR const char *filename,
 void __gcov_info_to_gcda(FAR const struct gcov_info *info,
                          FAR void (*filename_fn)(FAR const char *,
                                                  FAR void *),
-                         FAR void (*dump_fn)(FAR const void *, unsigned int,
+                         FAR void (*dump_fn)(FAR const void *, size_t,
                                              FAR void *),
                          FAR void *(*allocate_fn)(unsigned int, FAR void *),
                          FAR void *arg)

Reply via email to