Browse Source

if you have a function that takes const arguments and then
e.g. tries to copy StrCmp, gcc will give you warnings about those
calls, and the warnings are right. These clutter up other things you
might miss that you should be more concerned about.

You could work around it through vigorous typecasting to non-const
types, but why should you have to? All of these functions are
rigorously defined as not changing their input - it is const, and should
be marked as such.

Signed-off-by: Peter Jones <pjones@redhat.com>

Please enter the commit message for your changes. Lines starting

croxon 11 years ago
parent
commit
94009cecd7

+ 3 - 1
gnu-efi-3.0/inc/efidef.h

@@ -23,7 +23,9 @@ Revision History
 typedef UINT16          CHAR16;
 typedef UINT16          CHAR16;
 typedef UINT8           CHAR8;
 typedef UINT8           CHAR8;
 typedef UINT8           BOOLEAN;
 typedef UINT8           BOOLEAN;
-
+#ifndef CONST
+   #define CONST const
+#endif
 #ifndef TRUE
 #ifndef TRUE
     #define TRUE    ((BOOLEAN) 1)
     #define TRUE    ((BOOLEAN) 1)
     #define FALSE   ((BOOLEAN) 0)
     #define FALSE   ((BOOLEAN) 0)

+ 20 - 20
gnu-efi-3.0/inc/efilib.h

@@ -186,34 +186,34 @@ SetMem (
 VOID
 VOID
 CopyMem (
 CopyMem (
     IN VOID     *Dest,
     IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     );
     );
 
 
 INTN
 INTN
 CompareMem (
 CompareMem (
-    IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Dest,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     );
     );
 
 
 INTN
 INTN
 StrCmp (
 StrCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2
     );
     );
 
 
 INTN
 INTN
 StrnCmp (
 StrnCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2,
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2,
     IN UINTN    len
     IN UINTN    len
     );
     );
 
 
 INTN
 INTN
 StriCmp (
 StriCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2
     );
     );
 
 
 VOID
 VOID
@@ -229,51 +229,51 @@ StrUpr (
 VOID
 VOID
 StrCpy (
 StrCpy (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16    *Src
+    IN CONST CHAR16    *Src
     );
     );
 
 
 VOID
 VOID
 StrCat (
 StrCat (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     );
     );
 
 
 UINTN
 UINTN
 StrLen (
 StrLen (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     );
     );
 
 
 UINTN
 UINTN
 StrSize (
 StrSize (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     );
     );
 
 
 CHAR16 *
 CHAR16 *
 StrDuplicate (
 StrDuplicate (
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     );
     );
 
 
 UINTN
 UINTN
 strlena (
 strlena (
-    IN CHAR8    *s1
+    IN CONST CHAR8    *s1
     );
     );
     
     
 UINTN
 UINTN
 strcmpa (
 strcmpa (
-    IN CHAR8    *s1,
-    IN CHAR8    *s2
+    IN CONST CHAR8    *s1,
+    IN CONST CHAR8    *s2
     );
     );
 
 
 UINTN
 UINTN
 strncmpa (
 strncmpa (
-    IN CHAR8    *s1,
-    IN CHAR8    *s2,
+    IN CONST CHAR8    *s1,
+    IN CONST CHAR8    *s2,
     IN UINTN    len
     IN UINTN    len
     );
     );
 
 
 UINTN
 UINTN
 xtoi (
 xtoi (
-    CHAR16      *str
+    CONST CHAR16      *str
     );
     );
 
 
 UINTN
 UINTN

+ 9 - 9
gnu-efi-3.0/inc/efirtlib.h

@@ -42,23 +42,23 @@ VOID
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtCopyMem (
 RtCopyMem (
     IN VOID     *Dest,
     IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     );
     );
 
 
 INTN
 INTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtCompareMem (
 RtCompareMem (
-    IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Dest,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     );
     );
 
 
 INTN
 INTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrCmp (
 RtStrCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2
     );
     );
 
 
 
 
@@ -66,26 +66,26 @@ VOID
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrCpy (
 RtStrCpy (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16    *Src
+    IN CONST CHAR16    *Src
     );
     );
 
 
 VOID
 VOID
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrCat (
 RtStrCat (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     );
     );
 
 
 UINTN
 UINTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrLen (
 RtStrLen (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     );
     );
 
 
 UINTN
 UINTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrSize (
 RtStrSize (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     );
     );
 
 
 INTN
 INTN

+ 3 - 3
gnu-efi-3.0/lib/misc.c

@@ -111,7 +111,7 @@ SetMem (
 VOID
 VOID
 CopyMem (
 CopyMem (
     IN VOID     *Dest,
     IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     )
     )
 {
 {
@@ -120,8 +120,8 @@ CopyMem (
 
 
 INTN
 INTN
 CompareMem (
 CompareMem (
-    IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Dest,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     )
     )
 {
 {

+ 6 - 10
gnu-efi-3.0/lib/runtime/efirtlib.c

@@ -64,14 +64,13 @@ VOID
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtCopyMem (
 RtCopyMem (
     IN VOID     *Dest,
     IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     )
     )
 {
 {
-    CHAR8    *d, *s;
-
+    CHAR8   *d;
+    CONST CHAR8 *s = Src;
     d = Dest;
     d = Dest;
-    s = Src;
     while (len--) {
     while (len--) {
         *(d++) = *(s++);
         *(d++) = *(s++);
     }
     }
@@ -83,15 +82,12 @@ RtCopyMem (
 INTN
 INTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtCompareMem (
 RtCompareMem (
-    IN VOID     *Dest,
-    IN VOID     *Src,
+    IN CONST VOID     *Dest,
+    IN CONST VOID     *Src,
     IN UINTN    len
     IN UINTN    len
     )
     )
 {
 {
-    CHAR8    *d, *s;
-
-    d = Dest;
-    s = Src;
+    CONST CHAR8    *d = Dest, *s = Src;
     while (len--) {
     while (len--) {
         if (*d != *s) {
         if (*d != *s) {
             return *d - *s;
             return *d - *s;

+ 6 - 6
gnu-efi-3.0/lib/runtime/rtstr.c

@@ -23,8 +23,8 @@ Revision History
 INTN
 INTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrCmp (
 RtStrCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2
     )
     )
 // compare strings
 // compare strings
 {
 {
@@ -47,7 +47,7 @@ VOID
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrCpy (
 RtStrCpy (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     )
     )
 // copy strings
 // copy strings
 {
 {
@@ -64,7 +64,7 @@ VOID
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrCat (
 RtStrCat (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     )
     )
 {   
 {   
     RtStrCpy(Dest+StrLen(Dest), Src);
     RtStrCpy(Dest+StrLen(Dest), Src);
@@ -76,7 +76,7 @@ RtStrCat (
 UINTN
 UINTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrLen (
 RtStrLen (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     )
     )
 // string length
 // string length
 {
 {
@@ -92,7 +92,7 @@ RtStrLen (
 UINTN
 UINTN
 RUNTIMEFUNCTION
 RUNTIMEFUNCTION
 RtStrSize (
 RtStrSize (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     )
     )
 // string size
 // string size
 {
 {

+ 20 - 20
gnu-efi-3.0/lib/str.c

@@ -20,8 +20,8 @@ Revision History
 
 
 INTN
 INTN
 StrCmp (
 StrCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2
     )
     )
 // compare strings
 // compare strings
 {
 {
@@ -30,8 +30,8 @@ StrCmp (
 
 
 INTN
 INTN
 StrnCmp (
 StrnCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2,
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2,
     IN UINTN    len
     IN UINTN    len
     )
     )
 // compare strings
 // compare strings
@@ -70,15 +70,15 @@ LibStubStrLwrUpr (
 
 
 INTN
 INTN
 StriCmp (
 StriCmp (
-    IN CHAR16   *s1,
-    IN CHAR16   *s2
+    IN CONST CHAR16   *s1,
+    IN CONST CHAR16   *s2
     )
     )
 // compare strings
 // compare strings
 {
 {
     if (UnicodeInterface == &LibStubUnicodeInterface)
     if (UnicodeInterface == &LibStubUnicodeInterface)
-    	return UnicodeInterface->StriColl(UnicodeInterface, s1, s2);
+    	return UnicodeInterface->StriColl(UnicodeInterface, (CHAR16 *)s1, (CHAR16 *)s2);
     else
     else
-	return uefi_call_wrapper(UnicodeInterface->StriColl, 3, UnicodeInterface, s1, s2);
+	return uefi_call_wrapper(UnicodeInterface->StriColl, 3, UnicodeInterface, (CHAR16 *)s1, (CHAR16 *)s2);
 }
 }
 
 
 VOID
 VOID
@@ -106,7 +106,7 @@ StrUpr (
 VOID
 VOID
 StrCpy (
 StrCpy (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     )
     )
 // copy strings
 // copy strings
 {
 {
@@ -116,7 +116,7 @@ StrCpy (
 VOID
 VOID
 StrCat (
 StrCat (
     IN CHAR16   *Dest,
     IN CHAR16   *Dest,
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     )
     )
 {   
 {   
     RtStrCat(Dest, Src);
     RtStrCat(Dest, Src);
@@ -124,7 +124,7 @@ StrCat (
 
 
 UINTN
 UINTN
 StrLen (
 StrLen (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     )
     )
 // string length
 // string length
 {
 {
@@ -133,7 +133,7 @@ StrLen (
 
 
 UINTN
 UINTN
 StrSize (
 StrSize (
-    IN CHAR16   *s1
+    IN CONST CHAR16   *s1
     )
     )
 // string size
 // string size
 {
 {
@@ -142,7 +142,7 @@ StrSize (
 
 
 CHAR16 *
 CHAR16 *
 StrDuplicate (
 StrDuplicate (
-    IN CHAR16   *Src
+    IN CONST CHAR16   *Src
     )
     )
 // duplicate a string
 // duplicate a string
 {
 {
@@ -159,7 +159,7 @@ StrDuplicate (
 
 
 UINTN
 UINTN
 strlena (
 strlena (
-    IN CHAR8    *s1
+    IN CONST CHAR8    *s1
     )
     )
 // string length
 // string length
 {
 {
@@ -171,8 +171,8 @@ strlena (
 
 
 UINTN
 UINTN
 strcmpa (
 strcmpa (
-    IN CHAR8    *s1,
-    IN CHAR8    *s2
+    IN CONST CHAR8    *s1,
+    IN CONST CHAR8    *s2
     )
     )
 // compare strings
 // compare strings
 {
 {
@@ -190,8 +190,8 @@ strcmpa (
 
 
 UINTN
 UINTN
 strncmpa (
 strncmpa (
-    IN CHAR8    *s1,
-    IN CHAR8    *s2,
+    IN CONST CHAR8    *s1,
+    IN CONST CHAR8    *s2,
     IN UINTN    len
     IN UINTN    len
     )
     )
 // compare strings
 // compare strings
@@ -213,7 +213,7 @@ strncmpa (
 
 
 UINTN
 UINTN
 xtoi (
 xtoi (
-    CHAR16  *str
+    CONST CHAR16  *str
     )
     )
 // convert hex string to uint
 // convert hex string to uint
 {
 {
@@ -244,7 +244,7 @@ xtoi (
 
 
 UINTN
 UINTN
 Atoi (
 Atoi (
-    CHAR16  *str
+    CONST CHAR16  *str
     )
     )
 // convert hex string to uint
 // convert hex string to uint
 {
 {