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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2413a2a4c testing/memstress:Initialize the pointer to avoid the 
pointer being unknown when the memory alloc fails
2413a2a4c is described below

commit 2413a2a4c8b66e9e86a9bab47f2afcea75236474
Author: chenrun1 <[email protected]>
AuthorDate: Mon Mar 25 17:31:16 2024 +0800

    testing/memstress:Initialize the pointer to avoid the pointer being unknown 
when the memory alloc fails
    
    Summary:
      fix warning
    
    In function 'memorystress_iter',
        inlined from 'memstress_main' at memorystress_main.c:475:10:
    memorystress_main.c:289:10: error: 'ptr' may be used uninitialized 
[-Werror=maybe-uninitialized]
      289 |       if (ptr == NULL)
          |          ^
    memorystress_main.c: In function 'memstress_main':
    memorystress_main.c:248:20: note: 'ptr' was declared here
      248 |       FAR uint8_t *ptr;
          |                    ^~~
    
    Signed-off-by: chenrun1 <[email protected]>
---
 testing/memstress/memorystress_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testing/memstress/memorystress_main.c 
b/testing/memstress/memorystress_main.c
index dd8ff01e3..5ff79691f 100644
--- a/testing/memstress/memorystress_main.c
+++ b/testing/memstress/memorystress_main.c
@@ -245,7 +245,7 @@ static bool memorystress_iter(FAR struct 
memorystress_context_s *context)
     {
       /* Selection of test type and test size by random number */
 
-      FAR uint8_t *ptr;
+      FAR uint8_t *ptr = NULL;
       size_t size = randnum(context->config->max_allocsize, &seed);
       int switch_func = randnum(3, &seed);
       int align = 1 << (randnum(4, &seed) + 2);

Reply via email to