From 6eef43d013645514ffc345137e68e32e04382c98 Mon Sep 17 00:00:00 2001 From: espie Date: Fri, 23 Jan 2015 22:35:57 +0000 Subject: [PATCH] a wee little bit more cleanup (more const and remove noise from CDIAGFLAGS... -pedantic kind of requires -std=c99 here to avoid LL warnings) okay miod@, millert@ --- usr.bin/make/Makefile | 4 ++-- usr.bin/make/dir.c | 4 ++-- usr.bin/make/direxpand.c | 4 ++-- usr.bin/make/dump.c | 4 ++-- usr.bin/make/dump.h | 4 ++-- usr.bin/make/main.c | 4 ++-- usr.bin/make/parse.c | 3 ++- usr.bin/make/suff.c | 4 ++-- usr.bin/make/targ.c | 4 ++-- usr.bin/make/varmodifiers.c | 22 +++++++++++----------- 10 files changed, 29 insertions(+), 28 deletions(-) diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 055b2382c10..0f987fb2ef7 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.58 2014/05/12 19:11:19 espie Exp $ +# $OpenBSD: Makefile,v 1.59 2015/01/23 22:35:57 espie Exp $ PROG= make CFLAGS+= -I${.OBJDIR} -I${.CURDIR} HOSTCFLAGS+= -I${.OBJDIR} -I${.CURDIR} CDIAGFLAGS=-Wall -W -Wno-char-subscripts -Wstrict-prototypes -pedantic \ - -Wmissing-prototypes -Wdeclaration-after-statement + -Wmissing-prototypes -Wdeclaration-after-statement -std=c99 CDEFS+=-DHAS_BOOL_H CDEFS+=-DHAS_PATHS_H diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 3ad73c9499e..279191c3c0a 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.66 2015/01/23 13:18:40 espie Exp $ */ +/* $OpenBSD: dir.c,v 1.67 2015/01/23 22:35:57 espie Exp $ */ /* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */ /* @@ -686,7 +686,7 @@ Dir_Concat(Lst path1, Lst path2) static void DirPrintDir(void *p) { - struct PathEntry *q = p; + const struct PathEntry *q = p; printf("%s ", q->name); } diff --git a/usr.bin/make/direxpand.c b/usr.bin/make/direxpand.c index db29246b7a3..596af24fb79 100644 --- a/usr.bin/make/direxpand.c +++ b/usr.bin/make/direxpand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: direxpand.c,v 1.6 2015/01/23 13:18:40 espie Exp $ */ +/* $OpenBSD: direxpand.c,v 1.7 2015/01/23 22:35:57 espie Exp $ */ /* * Copyright (c) 1999,2007 Marc Espie. * @@ -298,7 +298,7 @@ Dir_Expandi(const char *word, const char *eword, Lst path, Lst expansions) static void DirPrintWord(void *word) { - char *s = word; + const char *s = word; printf("%s ", s); } diff --git a/usr.bin/make/dump.c b/usr.bin/make/dump.c index accba322f83..c661d5a01bd 100644 --- a/usr.bin/make/dump.c +++ b/usr.bin/make/dump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.c,v 1.7 2015/01/23 13:18:40 espie Exp $ */ +/* $OpenBSD: dump.c,v 1.8 2015/01/23 22:35:57 espie Exp $ */ /* * Copyright (c) 2012 Marc Espie. * @@ -82,7 +82,7 @@ sort_ohash(struct ohash *h, int (*comparison)(const void *, const void *)) static void TargPrintName(void *gnp) { - GNode *gn = gnp; + const GNode *gn = gnp; printf("%s ", gn->name); } diff --git a/usr.bin/make/dump.h b/usr.bin/make/dump.h index efabc9efe72..0825a98be36 100644 --- a/usr.bin/make/dump.h +++ b/usr.bin/make/dump.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dump.h,v 1.2 2012/10/02 10:29:30 espie Exp $ */ +/* $OpenBSD: dump.h,v 1.3 2015/01/23 22:35:57 espie Exp $ */ #ifndef _DUMP_H_ #define _DUMP_H_ @@ -46,6 +46,6 @@ extern void *sort_ohash_by_name(struct ohash *); * function. * free(t) when done with it. */ -extern void * sort_ohash(struct ohash *, int (*)(const void *, const void *)); +extern void *sort_ohash(struct ohash *, int (*)(const void *, const void *)); #endif diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index fc2c498d947..8ebc7536376 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.107 2015/01/23 13:18:40 espie Exp $ */ +/* $OpenBSD: main.c,v 1.108 2015/01/23 22:35:57 espie Exp $ */ /* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */ /* @@ -803,7 +803,7 @@ main(int argc, char **argv) static bool ReadMakefile(void *p, void *q) { - char *fname = p; /* makefile to read */ + const char *fname = p; /* makefile to read */ struct dirs *d = q; FILE *stream; char *name; diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index bf506b58036..5e83ff29948 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.111 2015/01/23 13:18:40 espie Exp $ */ +/* $OpenBSD: parse.c,v 1.112 2015/01/23 22:35:57 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* @@ -479,6 +479,7 @@ static int ParseFindMain(void *gnp, void *dummy UNUSED) { GNode *gn = gnp; + if ((gn->type & OP_NOTARGET) == 0 && gn->special == SPECIAL_NONE) { mainNode = gn; return 0; diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index 359657295cc..a78f680e55d 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: suff.c,v 1.89 2015/01/23 13:18:40 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.90 2015/01/23 22:35:58 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -1712,7 +1712,7 @@ Suff_Init(void) static void SuffPrintName(void *p) { - Suff *s = p; + const Suff *s = p; printf("%s ", s == emptySuff ? "" : s->name); } diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 134bbde2f02..e1baa194eca 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: targ.c,v 1.75 2014/05/12 19:11:19 espie Exp $ */ +/* $OpenBSD: targ.c,v 1.76 2015/01/23 22:35:58 espie Exp $ */ /* $NetBSD: targ.c,v 1.11 1997/02/20 16:51:50 christos Exp $ */ /* @@ -256,7 +256,7 @@ Targ_Precious(GNode *gn) void Targ_PrintCmd(void *p) { - struct command *cmd = p; + const struct command *cmd = p; printf("\t%s\n", cmd->string); } diff --git a/usr.bin/make/varmodifiers.c b/usr.bin/make/varmodifiers.c index 48f69c09a70..2c9229a5842 100644 --- a/usr.bin/make/varmodifiers.c +++ b/usr.bin/make/varmodifiers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: varmodifiers.c,v 1.40 2015/01/23 13:18:40 espie Exp $ */ +/* $OpenBSD: varmodifiers.c,v 1.41 2015/01/23 22:35:58 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -356,7 +356,7 @@ static bool VarMatch(struct Name *word, bool addSpace, Buffer buf, void *pattern) /* Pattern the word must match */ { - const char *pat = (const char *)pattern; + const char *pat = pattern; if (Str_Matchi(word->s, word->e, pat, strchr(pat, '\0'))) { if (addSpace) @@ -377,7 +377,7 @@ static bool VarNoMatch(struct Name *word, bool addSpace, Buffer buf, void *pattern) /* Pattern the word must not match */ { - const char *pat = (const char *)pattern; + const char *pat = pattern; if (!Str_Matchi(word->s, word->e, pat, strchr(pat, '\0'))) { if (addSpace) @@ -428,28 +428,28 @@ finish_loop(const char *s, const struct Name *n UNUSED , void *p) static int NameCompare(const void *ap, const void *bp) { - struct Name *a, *b; + const struct Name *a, *b; size_t n, m; int c; - a = (struct Name *)ap; - b = (struct Name *)bp; + a = ap; + b = bp; n = a->e - a->s; m = b->e - b->s; if (n < m) { c = strncmp(a->s, b->s, n); if (c != 0) - return c; + return c; else - return -1; + return -1; } else if (m < n) { c = strncmp(a->s, b->s, m); if (c != 0) - return c; + return c; else - return 1; + return 1; } else - return strncmp(a->s, b->s, n); + return strncmp(a->s, b->s, n); } static char * -- 2.20.1