1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 01:23:49 +01:00

tree-wide: add the NONSTRING attribute where needed

This declares all char arrays that intentionally are lacking the
terminated zero byte as `NONSTRING`.
This commit is contained in:
Marian Buschsieweke 2025-04-26 20:32:23 +02:00
parent 0b01fa0025
commit 1b70a59ded
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6
7 changed files with 27 additions and 0 deletions

View File

@ -27,12 +27,14 @@
#include <time.h>
#include <unistd.h>
#include "compiler_hints.h"
#include "container.h"
#include "fmt.h"
#include "modules.h"
extern ssize_t stdio_write(const void* buffer, size_t len);
NONSTRING
static const char _hex_chars[16] = "0123456789ABCDEF";
static const uint32_t _tenmap[] = {

View File

@ -24,9 +24,11 @@
#include <unistd.h>
#include <string.h>
#include "compiler_hints.h"
#include "fmt.h"
#include "fmt_table.h"
NONSTRING
static const char fmt_table_spaces[16] = " ";
/**

View File

@ -22,15 +22,20 @@
#include <string.h>
#include "base64.h"
#include "compiler_hints.h"
#include "fmt.h"
#include "macros/utils.h"
#include "xtimer.h"
static char buf[128];
/* no need for the zero-termination here, base64_encode() gets the size of the
* string as explicit argument */
NONSTRING
static const char input[96] = "This is an extremely, enormously, greatly, "
"immensely, tremendously, remarkably lengthy "
"sentence!";
NONSTRING
static const char base64[128] =
"VGhpcyBpcyBhbiBleHRyZW1lbHksIGVub3Jtb3VzbHksIGdyZWF0bHksIGltbWVuc2VseSwgdHJl"
"bWVuZG91c2x5LCByZW1hcmthYmx5IGxlbmd0aHkgc2VudGVuY2Uh";

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include "embUnit.h"
#include "compiler_hints.h"
#include "psa/crypto.h"
void addFailurePSA(const char *func, psa_status_t errcode, long line, const char *file)
@ -73,7 +74,9 @@ static void test_hash_interleaved(void)
{
const psa_algorithm_t alg = PSA_ALG_SHA_256;
NONSTRING
const uint8_t in1[1] = "a";
NONSTRING
const uint8_t in2[1] = "b";
const uint8_t exp1[] = {

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdint.h>
#include "compiler_hints.h"
#include "psa/crypto.h"
/*
@ -42,6 +43,7 @@ static const uint8_t public_key[] = {0x04, 0x60, 0xFE, 0xD4, 0xBA, 0x25, 0x5A, 0
/* certain PSA backends require the data to be in RAM rather than ROM
* so these values cannot be `const` */
NONSTRING
static uint8_t message[6] = "sample";
static uint8_t signature[] = {0xEF, 0xD4, 0x8B, 0x2A, 0xAC, 0xB6, 0xA8, 0xFD, 0x11, 0x40,
0xDD, 0x9C, 0xD4, 0x5E, 0x81, 0xD6, 0x9D, 0x2C, 0x87, 0x7B, 0x56, 0xAA, 0xF9, 0x91, 0xC3, 0x4D,

View File

@ -29,17 +29,21 @@
#include <stdlib.h>
#include <stdbool.h>
#include "compiler_hints.h"
#include "shell.h"
#include "tm.h"
NONSTRING
static const char MON_NAMES[12][3] = {
"JAN", "FEB", "MAR", "APR",
"MAY", "JUN", "JUL", "AUG",
"SEP", "OCT", "NOV", "DEC",
};
NONSTRING
static const char DAY_NAMES[7][3] = {
"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
};
NONSTRING
static const char BOOL_NAMES[2][3] = { "NO", "YES" };
bool proper_atoi(const char *a, int *i)

View File

@ -17,6 +17,7 @@
#include "embUnit/embUnit.h"
#include "compiler_hints.h"
#include "fmt.h"
#include "tests-fmt.h"
@ -244,6 +245,7 @@ static void test_fmt_hex_bytes(void)
static void test_fmt_u16_hex(void)
{
NONSTRING
char out[8] = "zzzzzzzz";
/* Check return count with null buffer input */
@ -260,6 +262,7 @@ static void test_fmt_u16_hex(void)
static void test_fmt_u32_hex(void)
{
NONSTRING
char out[12] = "zzzzzzzzzzzz";
/* Check return count with null buffer input */
@ -276,6 +279,7 @@ static void test_fmt_u32_hex(void)
static void test_fmt_u64_hex(void)
{
NONSTRING
char out[20] = "zzzzzzzzzzzzzzzzzzzz";
/* Check return count with null buffer input */
@ -292,6 +296,7 @@ static void test_fmt_u64_hex(void)
static void test_fmt_u16_dec(void)
{
NONSTRING
char out[8] = "zzzzzzzz";
uint8_t chars = 0;
@ -310,6 +315,7 @@ static void test_fmt_u16_dec(void)
static void test_fmt_u32_dec(void)
{
NONSTRING
char out[16] = "zzzzzzzzzzzzzzzz";
uint8_t chars = 0;
@ -329,6 +335,7 @@ static void test_fmt_u32_dec(void)
static void test_fmt_u64_dec(void)
{
NONSTRING
char out[24] = "zzzzzzzzzzzzzzzzzzzzzzzz";
uint8_t chars = 0;
@ -345,6 +352,7 @@ static void test_fmt_u64_dec(void)
static void test_fmt_u64_dec_zero(void)
{
NONSTRING
char out[24] = "zzzzzzzzzzzzzzzzzzzzzzzz";
uint8_t chars = 0;
@ -355,6 +363,7 @@ static void test_fmt_u64_dec_zero(void)
static void test_fmt_u64_dec_u64max(void)
{
NONSTRING
char out[24] = "zzzzzzzzzzzzzzzzzzzzzzzz";
uint8_t chars = 0;