Skip to content

Commit f2898de

Browse files
committed
Improve unconstify() documentation
Refer to expression instead of variable when appropriate. Discussion: https://www.postgresql.org/message-id/08adbe4e-38f8-2c73-55f0-591392371687%402ndquadrant.com
1 parent 4beea55 commit f2898de

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/include/c.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,28 +1122,28 @@ typedef union PGAlignedXLogBlock
11221122
#endif
11231123

11241124
/*
1125-
* Macro that allows to cast constness away from a variable, but doesn't
1125+
* Macro that allows to cast constness away from an expression, but doesn't
11261126
* allow changing the underlying type. Enforcement of the latter
11271127
* currently only works for gcc like compilers.
11281128
*
1129-
* Please note IT IS NOT SAFE to cast constness away if the variable will ever
1129+
* Please note IT IS NOT SAFE to cast constness away if the result will ever
11301130
* be modified (it would be undefined behaviour). Doing so anyway can cause
11311131
* compiler misoptimizations or runtime crashes (modifying readonly memory).
1132-
* It is only safe to use when the the variable will not be modified, but API
1132+
* It is only safe to use when the the result will not be modified, but API
11331133
* design or language restrictions prevent you from declaring that
11341134
* (e.g. because a function returns both const and non-const variables).
11351135
*
11361136
* Note that this only works in function scope, not for global variables (it'd
11371137
* be nice, but not trivial, to improve that).
11381138
*/
11391139
#if defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)
1140-
#define unconstify(underlying_type, var) \
1141-
(StaticAssertExpr(__builtin_types_compatible_p(__typeof(var), const underlying_type), \
1140+
#define unconstify(underlying_type, expr) \
1141+
(StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \
11421142
"wrong cast"), \
1143-
(underlying_type) (var))
1143+
(underlying_type) (expr))
11441144
#else
1145-
#define unconstify(underlying_type, var) \
1146-
((underlying_type) (var))
1145+
#define unconstify(underlying_type, expr) \
1146+
((underlying_type) (expr))
11471147
#endif
11481148

11491149
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy