Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/mkdep deconst -> __UNCONST to avoid null pointer ari...



details:   https://anonhg.NetBSD.org/src/rev/71a6031c05f4
branches:  trunk
changeset: 319282:71a6031c05f4
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed May 23 21:20:20 2018 +0000

description:
deconst -> __UNCONST to avoid null pointer arithmetic

diffstat:

 usr.bin/mkdep/mkdep.c |  14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diffs (42 lines):

diff -r 12e5d9f99e5d -r 71a6031c05f4 usr.bin/mkdep/mkdep.c
--- a/usr.bin/mkdep/mkdep.c     Wed May 23 21:16:57 2018 +0000
+++ b/usr.bin/mkdep/mkdep.c     Wed May 23 21:20:20 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkdep.c,v 1.44 2015/06/16 22:54:10 christos Exp $ */
+/* $NetBSD: mkdep.c,v 1.45 2018/05/23 21:20:20 joerg Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 #if !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\
  All rights reserved.");
-__RCSID("$NetBSD: mkdep.c,v 1.44 2015/06/16 22:54:10 christos Exp $");
+__RCSID("$NetBSD: mkdep.c,v 1.45 2018/05/23 21:20:20 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/mman.h>
@@ -82,12 +82,6 @@
 static void save_for_optional(const char *, const char *);
 static size_t write_optional(int, opt_t *, size_t);
 
-static inline void *
-deconst(const void *p)
-{
-       return (const char *)p - (const char *)0 + (char *)0;
-}
-
 __dead static void
 usage(void)
 {
@@ -119,8 +113,8 @@
        if ((args = malloc((argc + 3) * sizeof(char *))) == NULL)
                err(EXIT_FAILURE, "malloc");
 
-       args[0] = deconst(CC);
-       args[1] = deconst("-M");
+       args[0] = __UNCONST(CC);
+       args[1] = __UNCONST("-M");
        (void)memcpy(&args[2], argv, (argc + 1) * sizeof(char *));
 
        if ((tmpdir = getenv("TMPDIR")) == NULL)



Home | Main Index | Thread Index | Old Index