Skip to content

Commit a500027

Browse files
committed
PERL_STRLEN_ROUNDUP: parenthesize macro parameter
Also: - factor out common expression - remove redundant double parens - add spaces to expression
1 parent 9f8d27b commit a500027

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

handy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,7 @@ PoisonWith(0xEF) for catching access to freed memory.
22962296

22972297
#define MEM_SIZE_MAX ((MEM_SIZE)~0)
22982298

2299+
#define _PERL_STRLEN_ROUNDUP_UNCHECKED(n) (((n) - 1 + PERL_STRLEN_ROUNDUP_QUANTUM) & ~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM - 1))
22992300

23002301
#ifdef PERL_MALLOC_WRAP
23012302

@@ -2343,15 +2344,15 @@ PoisonWith(0xEF) for catching access to freed memory.
23432344

23442345
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
23452346

2346-
#define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (croak_memory_wrap(),0):0),((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1)))
2347+
#define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > MEM_SIZE_MAX - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (croak_memory_wrap(),0) : 0), _PERL_STRLEN_ROUNDUP_UNCHECKED(n))
23472348
#else
23482349

23492350
#define MEM_WRAP_CHECK(n,t)
23502351
#define MEM_WRAP_CHECK_1(n,t,a)
23512352
#define MEM_WRAP_CHECK_2(n,t,a,b)
23522353
#define MEM_WRAP_CHECK_(n,t)
23532354

2354-
#define PERL_STRLEN_ROUNDUP(n) (((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1)))
2355+
#define PERL_STRLEN_ROUNDUP(n) _PERL_STRLEN_ROUNDUP_UNCHECKED(n)
23552356

23562357
#endif
23572358

0 commit comments

Comments
 (0)