[PATCH] kunit: constify return of string literals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>

The function kunit_status_to_ok_not_ok() returns string literals, thus
declare the return value as such.

Reported by clang:

    ./include/kunit/test.h:143:10: warning: returning 'const char[3]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
      143 |                 return "ok";
          |                        ^~~~
    ./include/kunit/test.h:145:10: warning: returning 'const char[7]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
      145 |                 return "not ok";
          |                        ^~~~~~~~
    ./include/kunit/test.h:147:9: warning: returning 'const char[8]' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
      147 |         return "invalid";
          |                ^~~~~~~~~

Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
---
 include/kunit/test.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/kunit/test.h b/include/kunit/test.h
index 34b71e42fb10..ae1b57578476 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -135,7 +135,7 @@ struct kunit_case {
 	struct string_stream *log;
 };
 
-static inline char *kunit_status_to_ok_not_ok(enum kunit_status status)
+static inline const char *kunit_status_to_ok_not_ok(enum kunit_status status)
 {
 	switch (status) {
 	case KUNIT_SKIPPED:
-- 
2.45.2





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux