libc: fix sparse warning for __assert()
authorMasahiro Yamada <[email protected]>
Fri, 26 Jul 2019 11:21:39 +0000 (20:21 +0900)
committerMasahiro Yamada <[email protected]>
Wed, 11 Sep 2019 02:28:46 +0000 (11:28 +0900)
Sparse warns this:

lib/libc/assert.c:29:6: error: symbol '__assert' redeclared with different type (originally declared at include/lib/libc/assert.h:36) - different modifiers

Add __dead2 to match the header declaration and C definition.

I also changed '__dead2 void' to 'void __dead2' for the consistency
with other parts.

Change-Id: Iefa4f0e787c24fa7e7e499d2e7baf54d4deb49ef
Signed-off-by: Masahiro Yamada <[email protected]>
include/lib/libc/assert.h
lib/libc/assert.c

index d04f9dc043066c39a7a41839d8a0ad5a598b921c..486bbc29041b45a72d01422b2715048c7337fc70 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 #endif /* ENABLE_ASSERTIONS */
 
 #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
-__dead2 void __assert(const char *file, unsigned int line,
+void __dead2 __assert(const char *file, unsigned int line,
                      const char *assertion);
 #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
-__dead2 void __assert(const char *file, unsigned int line);
+void __dead2 __assert(const char *file, unsigned int line);
 #else
-__dead2 void __assert(void);
+void __dead2 __assert(void);
 #endif
 
 #endif /* ASSERT_H */
index 60f1a86605f132e62c81e1a6f39ccd118549b501..49f59db168b6e78d631489599d7367fbf6695df0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -18,7 +18,8 @@
  */
 
 #if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
-void __assert(const char *file, unsigned int line, const char *assertion)
+void __dead2 __assert(const char *file, unsigned int line,
+                     const char *assertion)
 {
        printf("ASSERT: %s:%d:%s\n", file, line, assertion);
        backtrace("assert");
@@ -26,7 +27,7 @@ void __assert(const char *file, unsigned int line, const char *assertion)
        plat_panic_handler();
 }
 #elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
-void __assert(const char *file, unsigned int line)
+void __dead2 __assert(const char *file, unsigned int line)
 {
        printf("ASSERT: %s:%d\n", file, line);
        backtrace("assert");
@@ -34,7 +35,7 @@ void __assert(const char *file, unsigned int line)
        plat_panic_handler();
 }
 #else
-void __assert(void)
+void __dead2 __assert(void)
 {
        backtrace("assert");
        (void)console_flush();
OSZAR »