@@ -39,7 +39,7 @@ void unreachableCode_error(void) // #11197
3939}
4040#endif
4141
42- int nullPointer_gethostbyname2_r (const char * name , int af , struct hostent * ret , char * buf , size_t buflen , struct hostent * * result , int * h_errnop )
42+ int nullPointer_gethostbyname2_r (const char * name , int af , struct hostent * ret , const char * buf , size_t buflen , struct hostent * * result , const int * h_errnop )
4343{
4444 // cppcheck-suppress nullPointer
4545 (void ) gethostbyname2_r (NULL , af , ret , buf , buflen , result , h_errnop );
@@ -54,7 +54,7 @@ int nullPointer_gethostbyname2_r(const char* name, int af, struct hostent* ret,
5454 return gethostbyname2_r (name , af , ret , buf , buflen , result , h_errnop );
5555}
5656
57- int nullPointer_gethostbyname_r (const char * name , struct hostent * ret , char * buf , size_t buflen , struct hostent * * result , int * h_errnop )
57+ int nullPointer_gethostbyname_r (const char * name , struct hostent * ret , const char * buf , size_t buflen , struct hostent * * result , const int * h_errnop )
5858{
5959 // cppcheck-suppress nullPointer
6060 (void ) gethostbyname_r (NULL , ret , buf , buflen , result , h_errnop );
@@ -70,7 +70,7 @@ int nullPointer_gethostbyname_r(const char* name, struct hostent* ret, char* buf
7070}
7171
7272
73- int nullPointer_gethostbyaddr_r (const void * addr , socklen_t len , int type , struct hostent * ret , char * buf , size_t buflen , struct hostent * * result , int * h_errnop )
73+ int nullPointer_gethostbyaddr_r (const void * addr , socklen_t len , int type , struct hostent * ret , const char * buf , size_t buflen , struct hostent * * result , const int * h_errnop )
7474{
7575 // cppcheck-suppress nullPointer
7676 (void ) gethostbyaddr_r (NULL , len , type , ret , buf , buflen , result , h_errnop );
@@ -109,7 +109,7 @@ int nullPointer_getopt_long_only(int argc, char* const* argv, const char* optstr
109109 return getopt_long_only (argc , argv , optstring , longopts , longindex );
110110}
111111
112- int nullPointer_getservent_r (struct servent * restrict result_buf , char * restrict buf , size_t buflen , struct servent * * restrict result )
112+ int nullPointer_getservent_r (struct servent * restrict result_buf , const char * restrict buf , size_t buflen , struct servent * * restrict result )
113113{
114114 // cppcheck-suppress nullPointer
115115 (void ) getservent_r (NULL , buf , buflen , result );
@@ -122,7 +122,7 @@ int nullPointer_getservent_r(struct servent *restrict result_buf, char *restrict
122122
123123void * bufferAccessOutOfBounds_memrchr (const void * s , int c , size_t n )
124124{
125- char buf [42 ]= {0 };
125+ const char buf [42 ]= {0 };
126126 (void )memrchr (buf ,c ,42 );
127127 // cppcheck-suppress bufferAccessOutOfBounds
128128 (void )memrchr (buf ,c ,43 );
@@ -275,17 +275,17 @@ int no_resourceLeak_mkostemp_02(char *template, int flags)
275275 return mkostemp (template , flags );
276276}
277277
278- void valid_code (int argInt1 , va_list valist_arg , int * parg )
278+ void valid_code (int argInt1 , va_list valist_arg , const int * parg )
279279{
280280 char * p ;
281281
282282 if (__builtin_expect (argInt1 , 0 )) {}
283283 if (__builtin_expect_with_probability (argInt1 + 1 , 2 , 0.5 )) {}
284284 if (__glibc_unlikely (argInt1 != 0 )) {}
285285 if (__glibc_likely (parg != NULL )) {}
286- void * ax1 = __builtin_assume_aligned (parg , 16 );
286+ const void * ax1 = __builtin_assume_aligned (parg , 16 );
287287 printf ("%p" , ax1 );
288- void * ax2 = __builtin_assume_aligned (parg , 32 , 8 );
288+ const void * ax2 = __builtin_assume_aligned (parg , 32 , 8 );
289289 printf ("%p" , ax2 );
290290
291291 p = (char * )malloc (10 );
@@ -316,7 +316,7 @@ void valid_code(int argInt1, va_list valist_arg, int * parg)
316316
317317 if (__alignof__(int ) == 4 ) {}
318318
319- void * p_mmap = mmap (NULL , 1 , PROT_NONE , MAP_ANONYMOUS | MAP_SHARED , -1 , 0 );
319+ const void * p_mmap = mmap (NULL , 1 , PROT_NONE , MAP_ANONYMOUS | MAP_SHARED , -1 , 0 );
320320 printf ("%p" , p_mmap );
321321 munmap (p_mmap , 1 );
322322
@@ -368,7 +368,7 @@ void memleak_xmalloc()
368368
369369void memleak_mmap ()
370370{
371- void * p_mmap = mmap (NULL , 1 , PROT_NONE , MAP_ANONYMOUS | MAP_SHARED , -1 , 0 );
371+ const void * p_mmap = mmap (NULL , 1 , PROT_NONE , MAP_ANONYMOUS | MAP_SHARED , -1 , 0 );
372372 printf ("%p" , p_mmap );
373373 // cppcheck-suppress memleak
374374}
@@ -391,7 +391,7 @@ void bufferAccessOutOfBounds__builtin_memset(void)
391391
392392void bufferAccessOutOfBounds ()
393393{
394- char buf [2 ] = "a" ;
394+ const char buf [2 ] = "a" ;
395395 // This is valid
396396 sethostname (buf , 2 );
397397 // cppcheck-suppress bufferAccessOutOfBounds
0 commit comments