* mdocml: To remove the const qualifier from a pointer to an object -
@ 2016-07-15 19:33 schwarze
2016-07-15 21:31 ` Joerg Sonnenberger
0 siblings, 1 reply; 2+ messages in thread
From: schwarze @ 2016-07-15 19:33 UTC (permalink / raw)
To: source
Log Message:
-----------
To remove the const qualifier from a pointer to an object - either
because we know it is actually mutable or because we are passing
it to a function that doesn't accept a const object but won't
actually attempt to modify it - simply casting from (const type *)
to (type *) is legal C and clearly expresses the intent.
So get rid of the obfuscating UNCONST macro.
Basic idea discussed with guenther@.
Modified Files:
--------------
mdocml:
main.c
main.h
Revision Data
-------------
Index: main.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -Lmain.h -Lmain.h -u -p -r1.25 -r1.26
--- main.h
+++ main.h
@@ -16,8 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
-
struct roff_man;
struct manoutput;
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.271
retrieving revision 1.272
diff -Lmain.c -Lmain.c -u -p -r1.271 -r1.272
--- main.c
+++ main.c
@@ -980,7 +980,7 @@ woptions(struct curparse *curp, char *ar
while (*arg) {
o = arg;
- switch (getsubopt(&arg, UNCONST(toks), &v)) {
+ switch (getsubopt(&arg, (char * const *)toks, &v)) {
case 0:
curp->wstop = 1;
break;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: mdocml: To remove the const qualifier from a pointer to an object -
2016-07-15 19:33 mdocml: To remove the const qualifier from a pointer to an object - schwarze
@ 2016-07-15 21:31 ` Joerg Sonnenberger
0 siblings, 0 replies; 2+ messages in thread
From: Joerg Sonnenberger @ 2016-07-15 21:31 UTC (permalink / raw)
To: source
On Fri, Jul 15, 2016 at 02:33:31PM -0500, schwarze@mdocml.bsd.lv wrote:
> To remove the const qualifier from a pointer to an object - either
> because we know it is actually mutable or because we are passing
> it to a function that doesn't accept a const object but won't
> actually attempt to modify it - simply casting from (const type *)
> to (type *) is legal C and clearly expresses the intent.
> So get rid of the obfuscating UNCONST macro.
> Basic idea discussed with guenther@.
This is completely wrong and a clear regression. The macro exists for
two reasons:
(1) It makes auditing easier by giving something simple to look for.
(2) The macro actually stopped -Wcast warnings. The replacement does
not.
Joerg
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-15 21:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 19:33 mdocml: To remove the const qualifier from a pointer to an object - schwarze
2016-07-15 21:31 ` Joerg Sonnenberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).