@@ -20,7 +20,7 @@ void __write_overflow_field(size_t avail, size_t wanted) __compiletime_warning("
2020({ \
2121 char *__p = (char *)(p); \
2222 size_t __ret = SIZE_MAX; \
23- size_t __p_size = __member_size(p); \
23+ const size_t __p_size = __member_size(p); \
2424 if (__p_size != SIZE_MAX && \
2525 __builtin_constant_p(*__p)) { \
2626 size_t __p_len = __p_size - 1; \
@@ -142,7 +142,7 @@ extern char *__underlying_strncpy(char *p, const char *q, __kernel_size_t size)
142142__FORTIFY_INLINE __diagnose_as (__builtin_strncpy , 1 , 2 , 3 )
143143char * strncpy (char * const POS p , const char * q , __kernel_size_t size )
144144{
145- size_t p_size = __member_size (p );
145+ const size_t p_size = __member_size (p );
146146
147147 if (__compiletime_lessthan (p_size , size ))
148148 __write_overflow ();
@@ -169,7 +169,7 @@ char *strncpy(char * const POS p, const char *q, __kernel_size_t size)
169169__FORTIFY_INLINE __diagnose_as (__builtin_strcat , 1 , 2 )
170170char * strcat (char * const POS p , const char * q )
171171{
172- size_t p_size = __member_size (p );
172+ const size_t p_size = __member_size (p );
173173
174174 if (p_size == SIZE_MAX )
175175 return __underlying_strcat (p , q );
@@ -191,8 +191,8 @@ extern __kernel_size_t __real_strnlen(const char *, __kernel_size_t) __RENAME(st
191191 */
192192__FORTIFY_INLINE __kernel_size_t strnlen (const char * const POS p , __kernel_size_t maxlen )
193193{
194- size_t p_size = __member_size (p );
195- size_t p_len = __compiletime_strlen (p );
194+ const size_t p_size = __member_size (p );
195+ const size_t p_len = __compiletime_strlen (p );
196196 size_t ret ;
197197
198198 /* We can take compile-time actions when maxlen is const. */
@@ -233,8 +233,8 @@ __FORTIFY_INLINE __kernel_size_t strnlen(const char * const POS p, __kernel_size
233233__FORTIFY_INLINE __diagnose_as (__builtin_strlen , 1 )
234234__kernel_size_t __fortify_strlen (const char * const POS p )
235235{
236+ const size_t p_size = __member_size (p );
236237 __kernel_size_t ret ;
237- size_t p_size = __member_size (p );
238238
239239 /* Give up if we don't know how large p is. */
240240 if (p_size == SIZE_MAX )
@@ -267,8 +267,8 @@ extern size_t __real_strlcpy(char *, const char *, size_t) __RENAME(strlcpy);
267267 */
268268__FORTIFY_INLINE size_t strlcpy (char * const POS p , const char * const POS q , size_t size )
269269{
270- size_t p_size = __member_size (p );
271- size_t q_size = __member_size (q );
270+ const size_t p_size = __member_size (p );
271+ const size_t q_size = __member_size (q );
272272 size_t q_len ; /* Full count of source string length. */
273273 size_t len ; /* Count of characters going into destination. */
274274
@@ -318,10 +318,10 @@ extern ssize_t __real_strscpy(char *, const char *, size_t) __RENAME(strscpy);
318318 */
319319__FORTIFY_INLINE ssize_t strscpy (char * const POS p , const char * const POS q , size_t size )
320320{
321- size_t len ;
322321 /* Use string size rather than possible enclosing struct size. */
323- size_t p_size = __member_size (p );
324- size_t q_size = __member_size (q );
322+ const size_t p_size = __member_size (p );
323+ const size_t q_size = __member_size (q );
324+ size_t len ;
325325
326326 /* If we cannot get size of p and q default to call strscpy. */
327327 if (p_size == SIZE_MAX && q_size == SIZE_MAX )
@@ -394,9 +394,9 @@ __FORTIFY_INLINE ssize_t strscpy(char * const POS p, const char * const POS q, s
394394__FORTIFY_INLINE __diagnose_as (__builtin_strncat , 1 , 2 , 3 )
395395char * strncat (char * const POS p , const char * const POS q , __kernel_size_t count )
396396{
397+ const size_t p_size = __member_size (p );
398+ const size_t q_size = __member_size (q );
397399 size_t p_len , copy_len ;
398- size_t p_size = __member_size (p );
399- size_t q_size = __member_size (q );
400400
401401 if (p_size == SIZE_MAX && q_size == SIZE_MAX )
402402 return __underlying_strncat (p , q , count );
@@ -639,7 +639,7 @@ __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size,
639639extern void * __real_memscan (void * , int , __kernel_size_t ) __RENAME (memscan );
640640__FORTIFY_INLINE void * memscan (void * const POS0 p , int c , __kernel_size_t size )
641641{
642- size_t p_size = __struct_size (p );
642+ const size_t p_size = __struct_size (p );
643643
644644 if (__compiletime_lessthan (p_size , size ))
645645 __read_overflow ();
@@ -651,8 +651,8 @@ __FORTIFY_INLINE void *memscan(void * const POS0 p, int c, __kernel_size_t size)
651651__FORTIFY_INLINE __diagnose_as (__builtin_memcmp , 1 , 2 , 3 )
652652int memcmp (const void * const POS0 p , const void * const POS0 q , __kernel_size_t size )
653653{
654- size_t p_size = __struct_size (p );
655- size_t q_size = __struct_size (q );
654+ const size_t p_size = __struct_size (p );
655+ const size_t q_size = __struct_size (q );
656656
657657 if (__builtin_constant_p (size )) {
658658 if (__compiletime_lessthan (p_size , size ))
@@ -668,7 +668,7 @@ int memcmp(const void * const POS0 p, const void * const POS0 q, __kernel_size_t
668668__FORTIFY_INLINE __diagnose_as (__builtin_memchr , 1 , 2 , 3 )
669669void * memchr (const void * const POS0 p , int c , __kernel_size_t size )
670670{
671- size_t p_size = __struct_size (p );
671+ const size_t p_size = __struct_size (p );
672672
673673 if (__compiletime_lessthan (p_size , size ))
674674 __read_overflow ();
@@ -680,7 +680,7 @@ void *memchr(const void * const POS0 p, int c, __kernel_size_t size)
680680void * __real_memchr_inv (const void * s , int c , size_t n ) __RENAME (memchr_inv );
681681__FORTIFY_INLINE void * memchr_inv (const void * const POS0 p , int c , size_t size )
682682{
683- size_t p_size = __struct_size (p );
683+ const size_t p_size = __struct_size (p );
684684
685685 if (__compiletime_lessthan (p_size , size ))
686686 __read_overflow ();
@@ -693,7 +693,7 @@ extern void *__real_kmemdup(const void *src, size_t len, gfp_t gfp) __RENAME(kme
693693 __realloc_size (2 );
694694__FORTIFY_INLINE void * kmemdup (const void * const POS0 p , size_t size , gfp_t gfp )
695695{
696- size_t p_size = __struct_size (p );
696+ const size_t p_size = __struct_size (p );
697697
698698 if (__compiletime_lessthan (p_size , size ))
699699 __read_overflow ();
@@ -720,8 +720,8 @@ __FORTIFY_INLINE void *kmemdup(const void * const POS0 p, size_t size, gfp_t gfp
720720__FORTIFY_INLINE __diagnose_as (__builtin_strcpy , 1 , 2 )
721721char * strcpy (char * const POS p , const char * const POS q )
722722{
723- size_t p_size = __member_size (p );
724- size_t q_size = __member_size (q );
723+ const size_t p_size = __member_size (p );
724+ const size_t q_size = __member_size (q );
725725 size_t size ;
726726
727727 /* If neither buffer size is known, immediately give up. */
0 commit comments