1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-06-20 01:17:49 +02:00

Add VR_NON_STRING macro for nonstring attribute.

The nonstring variable attribute specifies that an object or member declaration with type array of char, signed char, or unsigned char, or pointer to such a type is intended to store character arrays that do not necessarily contain a terminating NUL.

Newer versions of gcc will warn if this attribute is missing.
This commit is contained in:
David Steele
2025-06-22 15:38:32 -04:00
parent 44e3ee33d2
commit d0072945fa
3 changed files with 17 additions and 5 deletions
+12
View File
@@ -247,6 +247,18 @@ configuration.set(
description: 'Indicate that a function is formatted like strftime (and provide format position)'
)
# Set VR_NON_STRING macro
if cc.compiles(
'''int main(int arg, char **argv) {__attribute__((nonstring)) static char test[3] = "ABC";}''',
args: ['-Wextra', '-Werror'])
configuration.set(
'VR_NON_STRING', '__attribute__((nonstring))',
description: 'Indicate that the char array is intentionally not NULL terminated')
else
configuration.set(
'VR_NON_STRING', '', description: 'Indicate that the char array is intentionally not NULL terminated')
endif
####################################################################################################################################
# Include subdirs
####################################################################################################################################
+3 -3
View File
@@ -18,7 +18,7 @@ Assert that encoding type is valid. This needs to be kept up to date with the la
/***********************************************************************************************************************************
Base64 encoding/decoding
***********************************************************************************************************************************/
static const char encodeBase64Lookup[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
VR_NON_STRING static const char encodeBase64Lookup[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static void
encodeToStrBase64(const uint8_t *const source, const size_t sourceSize, char *const destination)
@@ -221,7 +221,7 @@ decodeToBinSizeBase64(const char *const source)
/***********************************************************************************************************************************
Base64Url encoding
***********************************************************************************************************************************/
static const char encodeBase64LookupUrl[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
VR_NON_STRING static const char encodeBase64LookupUrl[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
static void
encodeToStrBase64Url(const uint8_t *const source, const size_t sourceSize, char *const destination)
@@ -291,7 +291,7 @@ encodeToStrSizeBase64Url(const size_t sourceSize)
/***********************************************************************************************************************************
Hex encoding/decoding
***********************************************************************************************************************************/
static const char encodeHexLookup[512] =
VR_NON_STRING static const char encodeHexLookup[512] =
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
"202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
"404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f"
+2 -2
View File
@@ -287,7 +287,7 @@ strIdToZN(StringId strId, char *const buffer)
case stringIdBit5:
{
// Map to convert encoding to characters
static const char map[32] = "!abcdefghijklmnopqrstuvwxyz-256!";
VR_NON_STRING static const char map[32] = "!abcdefghijklmnopqrstuvwxyz-256!";
// Macro to decode all but the last character
#define STR5ID_TO_ZN_IDX(idx) \
@@ -330,7 +330,7 @@ strIdToZN(StringId strId, char *const buffer)
ASSERT(bit == stringIdBit6);
// Map to convert encoding to characters
static const char map[64] = "!abcdefghijklmnopqrstuvwxyz-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
VR_NON_STRING static const char map[64] = "!abcdefghijklmnopqrstuvwxyz-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// Macro to decode all but the last character
#define STR6ID_TO_ZN_IDX(idx) \