You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/03/07 15:27:25 UTC

[incubator-nuttx-apps] branch master updated: examples/chrono: Fix the compiler warning when -fno-builtin isn't set

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/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new b5f14a2  examples/chrono: Fix the compiler warning when -fno-builtin isn't set
b5f14a2 is described below

commit b5f14a20721b761a8a8e1b91683a954407cd30c7
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Mar 7 20:40:16 2022 +0800

    examples/chrono: Fix the compiler warning when -fno-builtin isn't set
    
    Error: chrono_main.c:434:51: error: '%01ld' directive output may be truncated writing between 1 and 3 bytes into a region of size between 2 and 10 [-Werror=format-truncation=]
      434 |           snprintf(str, sizeof(str), "%02ld:%02ld:%01ld",
          |                                                   ^~~~~
    chrono_main.c:434:38: note: directive argument in the range [-21, 21]
      434 |           snprintf(str, sizeof(str), "%02ld:%02ld:%01ld",
          |                                      ^~~~~~~~~~~~~~~~~~~
    chrono_main.c:434:11: note: 'snprintf' output between 8 and 18 bytes into a destination of size 16
      434 |           snprintf(str, sizeof(str), "%02ld:%02ld:%01ld",
          |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      435 |                    min, sec, (priv->ts_end.tv_nsec / 100000000));
          |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 examples/chrono/chrono_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/chrono/chrono_main.c b/examples/chrono/chrono_main.c
index 42f1a19..11a7705 100644
--- a/examples/chrono/chrono_main.c
+++ b/examples/chrono/chrono_main.c
@@ -298,7 +298,7 @@ static void slcd_puts(FAR struct lib_outstream_s *outstream,
 int main(int argc, FAR char *argv[])
 {
   FAR struct slcd_chrono_s *priv = &g_slcd;
-  FAR char str[16] = "00:00.0";
+  FAR char str[32] = "00:00.0";
   int fd;
   int ret;
   long sec;