Overview
| Artifact ID: | 0969894470936a6ba15cc113edd285502469928f1feaa6106d8a8daf4a5c2ebe |
|---|---|
| Ticket: | da6f155ca48c78c74eb40921ab3ac46a8cabc0af
STRING_SIZE() macro: parenthesize numChars usage |
| User & Date: | chrstphrchvz on 2021-12-24 19:19:54 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
I don’t observe anything broken due to the lack of parentheses around <tt>numChars</tt> in the <tt>STRING_SIZE()</tt> macro, but would it be a good idea to parenthesize it anyway to avoid surprises? <pre> diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h index 25b854ea4..59e9499a7 100644 --- a/generic/tclStringRep.h +++ b/generic/tclStringRep.h @@ -67,7 +67,7 @@ typedef struct String { #define STRING_MAXCHARS \ (int)(((size_t)UINT_MAX - 1 - TclOffset(String, unicode))/sizeof(Tcl_UniChar)) #define STRING_SIZE(numChars) \ <span style="color:red">- (TclOffset(String, unicode) + ((numChars + 1) * sizeof(Tcl_UniChar)))</span> <span style="color:green">+ (TclOffset(String, unicode) + (((numChars) + 1) * sizeof(Tcl_UniChar)))</span> #define stringCheckLimits(numChars) \ do { \ if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \ </pre> - foundin changed to: "8.6.12"
- is_private changed to: "0"
- login: "chrstphrchvz"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Cosmetic"
- status changed to: "Open"
- submitter changed to: "chrstphrchvz"
- subsystem changed to: "10. Objects"
- title changed to: "STRING_SIZE() macro: parenthesize numChars usage"
- type changed to: "Patch"