CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 17 22:29:11 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: main1.c Log Message: lint: extract suppress_messages from main No functional change. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/usr.bin/xlint/lint1/main1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.55 src/usr.bin/xlint/lint1/main1.c:1.56 --- src/usr.bin/xlint/lint1/main1.c:1.55 Tue Aug 17 21:19:02 2021 +++ src/usr.bin/xlint/lint1/main1.c Tue Aug 17 22:29:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $"); #endif #include @@ -168,11 +168,28 @@ sigfpe(int s) fpe = 1; } +static void +suppress_messages(char *ids) +{ + char *ptr, *end; + long id; + + for (ptr = strtok(ids, ","); ptr != NULL; ptr = strtok(NULL, ",")) { + errno = 0; + id = strtol(ptr, , 0); + if ((id == TARG_LONG_MIN || id == TARG_LONG_MAX) && + errno == ERANGE) + err(1, "invalid error message id '%s'", ptr); + if (*end != '\0' || ptr == end || id < 0 || id >= ERR_SETSIZE) + errx(1, "invalid error message id '%s'", ptr); + ERR_SET(id, ); + } +} + int main(int argc, char *argv[]) { - int c; - char *ptr; + int c; setprogname(argv[0]); @@ -217,23 +234,7 @@ main(int argc, char *argv[]) break; case 'X': - for (ptr = strtok(optarg, ","); ptr != NULL; - ptr = strtok(NULL, ",")) { -char *eptr; -long msg; - -errno = 0; -msg = strtol(ptr, , 0); -if ((msg == TARG_LONG_MIN || msg == TARG_LONG_MAX) && -errno == ERANGE) -err(1, "invalid error message id '%s'", - ptr); -if (*eptr != '\0' || ptr == eptr || msg < 0 || -msg >= ERR_SETSIZE) - errx(1, "invalid error message id '%s'", - ptr); -ERR_SET(msg, ); - } + suppress_messages(optarg); break; default: usage();
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 17 21:19:02 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: main1.c Log Message: lint: sync usage message with reality To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/usr.bin/xlint/lint1/main1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.54 src/usr.bin/xlint/lint1/main1.c:1.55 --- src/usr.bin/xlint/lint1/main1.c:1.54 Tue Aug 17 21:05:34 2021 +++ src/usr.bin/xlint/lint1/main1.c Tue Aug 17 21:19:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $"); #endif #include @@ -290,9 +290,9 @@ static void __attribute__((noreturn)) usage(void) { (void)fprintf(stderr, - "usage: %s [-abcdeghmprstuvwyzFST] [-Ac11] [-X [,]... " - "src dest\n", - getprogname()); + "usage: %s [-abceghmprstuvwyzFPST] [-Ac11] [-R old=new]\n" + " %*s [-X [,]...] src dest\n", + getprogname(), (int)strlen(getprogname()), ""); exit(1); }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 17 21:05:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: main1.c Log Message: lint: move GCC builtins into gcc_builtins No functional change. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/usr.bin/xlint/lint1/main1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.53 src/usr.bin/xlint/lint1/main1.c:1.54 --- src/usr.bin/xlint/lint1/main1.c:1.53 Sun Aug 1 19:11:54 2021 +++ src/usr.bin/xlint/lint1/main1.c Tue Aug 17 21:05:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.53 2021/08/01 19:11:54 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.53 2021/08/01 19:11:54 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $"); #endif #include @@ -130,16 +130,15 @@ sig_atomic_t fpe; static void usage(void); -static const char builtins[] = -"int __builtin_isinf(long double);\n" -"int __builtin_isnan(long double);\n" -"int __builtin_copysign(long double, long double);\n" -; -static const size_t builtinlen = sizeof(builtins) - 1; - static FILE * gcc_builtins(void) { + static const char builtins[] = + "int __builtin_isinf(long double);\n" + "int __builtin_isnan(long double);\n" + "int __builtin_copysign(long double, long double);\n"; + size_t builtins_len = sizeof(builtins) - 1; + #if HAVE_NBTOOL_CONFIG_H char template[] = "/tmp/lint.XX"; int fd; @@ -151,14 +150,14 @@ gcc_builtins(void) close(fd); return NULL; } - if (fwrite(builtins, 1, builtinlen, fp) != builtinlen) { + if (fwrite(builtins, 1, builtins_len, fp) != builtins_len) { fclose(fp); return NULL; } rewind(fp); return fp; #else - return fmemopen(__UNCONST(builtins), builtinlen, "r"); + return fmemopen(__UNCONST(builtins), builtins_len, "r"); #endif }
CVS commit: src/usr.bin/progress
Module Name:src Committed By: gson Date: Tue Aug 17 07:18:43 UTC 2021 Modified Files: src/usr.bin/progress: progress.c Log Message: Add missing check for error returns from read(). Found by inspection while reviewing the changes suggested by RVP in PR install/56303, but not believed to be the cause of the failure reported in that PR. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/progress/progress.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/progress/progress.c diff -u src/usr.bin/progress/progress.c:1.24 src/usr.bin/progress/progress.c:1.25 --- src/usr.bin/progress/progress.c:1.24 Mon Aug 9 10:46:39 2021 +++ src/usr.bin/progress/progress.c Tue Aug 17 07:18:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.24 2021/08/09 10:46:39 gson Exp $ */ +/* $NetBSD: progress.c,v 1.25 2021/08/17 07:18:43 gson Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progress.c,v 1.24 2021/08/09 10:46:39 gson Exp $"); +__RCSID("$NetBSD: progress.c,v 1.25 2021/08/17 07:18:43 gson Exp $"); #endif/* not lint */ #include @@ -231,7 +231,11 @@ main(int argc, char *argv[]) do { nr = read(fd, fb_buf, buffersize); } while (nr < 0 && errno == EINTR); - if (nr <= 0) + if (nr < 0) { + progressmeter(1); + err(1, "reading input"); + } + if (nr == 0) break; for (off = 0; nr; nr -= nw, off += nw, bytes += nw) if ((nw = write(outpipe[1], fb_buf + off,
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Aug 16 18:51:03 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: remove dead code from check_bad_enum_operation There is a single caller of that function, and it checks the exact same condition beforehand. To generate a diff of this commit: cvs rdiff -u -r1.336 -r1.337 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.336 src/usr.bin/xlint/lint1/tree.c:1.337 --- src/usr.bin/xlint/lint1/tree.c:1.336 Sun Aug 15 14:26:39 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Aug 16 18:51:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.336 2021/08/15 14:26:39 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.337 2021/08/16 18:51:03 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.336 2021/08/15 14:26:39 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.337 2021/08/16 18:51:03 rillig Exp $"); #endif #include @@ -1587,11 +1587,6 @@ check_bad_enum_operation(op_t op, const if (!eflag) return; - if (!(ln->tn_type->t_is_enum || - (modtab[op].m_binary && rn->tn_type->t_is_enum))) { - return; - } - /* * Enum as offset to a pointer is an exception (otherwise enums * could not be used as array indices). @@ -1604,7 +1599,6 @@ check_bad_enum_operation(op_t op, const /* dubious operation on enum, op %s */ warning(241, op_name(op)); - } /*
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 14 14:43:30 UTC 2021 Modified Files: src/usr.bin/make: arch.c Log Message: make: add ARGSUSED for lint To generate a diff of this commit: cvs rdiff -u -r1.201 -r1.202 src/usr.bin/make/arch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.201 src/usr.bin/make/arch.c:1.202 --- src/usr.bin/make/arch.c:1.201 Sat Aug 14 13:26:07 2021 +++ src/usr.bin/make/arch.c Sat Aug 14 14:43:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.202 2021/08/14 14:43:30 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.202 2021/08/14 14:43:30 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -988,6 +988,7 @@ Arch_FindLib(GNode *gn, SearchPath *path #endif } +/* ARGSUSED */ static bool RanlibOODate(const GNode *gn MAKE_ATTR_UNUSED) {
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 14 13:39:43 UTC 2021 Modified Files: src/usr.bin/make: parse.c Log Message: make: fix spelling of CVS and RCS in error message To generate a diff of this commit: cvs rdiff -u -r1.562 -r1.563 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.562 src/usr.bin/make/parse.c:1.563 --- src/usr.bin/make/parse.c:1.562 Sat Aug 14 13:37:55 2021 +++ src/usr.bin/make/parse.c Sat Aug 14 13:39:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.563 2021/08/14 13:39:43 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.563 2021/08/14 13:39:43 rillig Exp $"); /* types and constants */ @@ -1004,7 +1004,7 @@ ParseErrorNoDependency(const char *lstar (strncmp(lstart, "==", 6) == 0) || (strncmp(lstart, ">>", 6) == 0)) Parse_Error(PARSE_FATAL, - "Makefile appears to contain unresolved cvs/rcs/??? merge conflicts"); + "Makefile appears to contain unresolved CVS/RCS/??? merge conflicts"); else if (lstart[0] == '.') { const char *dirstart = lstart + 1; const char *dirend;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 14 13:37:56 UTC 2021 Modified Files: src/usr.bin/make: parse.c Log Message: make: rename ParseMark to be more expressive No functional change. To generate a diff of this commit: cvs rdiff -u -r1.561 -r1.562 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.561 src/usr.bin/make/parse.c:1.562 --- src/usr.bin/make/parse.c:1.561 Sat Aug 14 13:32:12 2021 +++ src/usr.bin/make/parse.c Sat Aug 14 13:37:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $"); /* types and constants */ @@ -530,7 +530,7 @@ ParseIsEscaped(const char *line, const c * was first defined. */ static void -ParseMark(GNode *gn) +RememberLocation(GNode *gn) { IFile *curFile = CurFile(); gn->fname = curFile->fname; @@ -782,7 +782,7 @@ TryApplyDependencyOperator(GNode *gn, GN cohort = Targ_NewInternalNode(gn->name); if (doing_depend) - ParseMark(cohort); + RememberLocation(cohort); /* * Make the cohort invisible as well to avoid duplicating it * into other variables. True, parents of this target won't @@ -837,7 +837,7 @@ ParseDependencySourceWait(bool isSpecial snprintf(wait_src, sizeof wait_src, ".WAIT_%u", ++wait_number); gn = Targ_NewInternalNode(wait_src); if (doing_depend) - ParseMark(gn); + RememberLocation(gn); gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN; LinkToTargets(gn, isSpecial); @@ -897,7 +897,7 @@ ParseDependencySourceOrder(const char *s */ gn = Targ_GetNode(src); if (doing_depend) - ParseMark(gn); + RememberLocation(gn); if (order_pred != NULL) { Lst_Append(_pred->order_succ, gn); Lst_Append(>order_pred, order_pred); @@ -934,7 +934,7 @@ ParseDependencySourceOther(const char *s /* Find/create the 'src' node and attach to all targets */ gn = Targ_GetNode(src); if (doing_depend) - ParseMark(gn); + RememberLocation(gn); if (tOp != OP_NONE) gn->type |= tOp; else @@ -1085,7 +1085,7 @@ ParseDependencyTargetSpecial(ParseSpecia case SP_INTERRUPT: { GNode *gn = Targ_GetNode(targetName); if (doing_depend) - ParseMark(gn); + RememberLocation(gn); gn->type |= OP_NOTMAIN | OP_SPECIAL; Lst_Append(targets, gn); break; @@ -1215,7 +1215,7 @@ ParseDependencyTargetMundane(char *targe ? Suff_AddTransform(targName) : Targ_GetNode(targName); if (doing_depend) - ParseMark(gn); + RememberLocation(gn); Lst_Append(targets, gn); } @@ -2084,7 +2084,7 @@ ParseAddCmd(GNode *gn, char *cmd) Lst_Append(>commands, cmd); if (MaybeSubMake(cmd)) gn->type |= OP_SUBMAKE; - ParseMark(gn); + RememberLocation(gn); } else { #if 0 /* XXX: We cannot do this until we fix the tree */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 14 13:32:12 UTC 2021 Modified Files: src/usr.bin/make: main.c nonints.h parse.c Log Message: make: rename variable and function for handling parse errors The word 'fatals' was an unnecessary abbreviation. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.540 -r1.541 src/usr.bin/make/main.c cvs rdiff -u -r1.213 -r1.214 src/usr.bin/make/nonints.h cvs rdiff -u -r1.560 -r1.561 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.540 src/usr.bin/make/main.c:1.541 --- src/usr.bin/make/main.c:1.540 Fri Jun 18 12:54:17 2021 +++ src/usr.bin/make/main.c Sat Aug 14 13:32:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.540 2021/06/18 12:54:17 rillig Exp $ */ +/* $NetBSD: main.c,v 1.541 2021/08/14 13:32:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.540 2021/06/18 12:54:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.541 2021/08/14 13:32:12 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1658,7 +1658,7 @@ main_CleanUp(void) static int main_Exit(bool outOfDate) { - if (opts.strict && (main_errors > 0 || Parse_GetFatals() > 0)) + if (opts.strict && (main_errors > 0 || Parse_NumErrors() > 0)) return 2; /* Not 1 so -q can distinguish error */ return outOfDate ? 1 : 0; } Index: src/usr.bin/make/nonints.h diff -u src/usr.bin/make/nonints.h:1.213 src/usr.bin/make/nonints.h:1.214 --- src/usr.bin/make/nonints.h:1.213 Sun Apr 11 13:35:56 2021 +++ src/usr.bin/make/nonints.h Sat Aug 14 13:32:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.213 2021/04/11 13:35:56 rillig Exp $ */ +/* $NetBSD: nonints.h,v 1.214 2021/08/14 13:32:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -164,7 +164,7 @@ void Parse_AddIncludeDir(const char *); void Parse_File(const char *, int); void Parse_SetInput(const char *, int, int, ReadMoreProc, void *); void Parse_MainName(GNodeList *); -int Parse_GetFatals(void); +int Parse_NumErrors(void); /* suff.c */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.560 src/usr.bin/make/parse.c:1.561 --- src/usr.bin/make/parse.c:1.560 Mon Jun 21 10:42:06 2021 +++ src/usr.bin/make/parse.c Sat Aug 14 13:32:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.560 2021/06/21 10:42:06 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.560 2021/06/21 10:42:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $"); /* types and constants */ @@ -218,7 +218,7 @@ static GNode *order_pred; /* parser state */ /* number of fatal errors */ -static int fatals = 0; +static int parseErrors = 0; /* * Variables for doing includes @@ -613,7 +613,7 @@ ParseVErrorInternal(FILE *f, const char goto print_stack_trace; if (type == PARSE_WARNING && !opts.parseWarnFatal) goto print_stack_trace; - fatals++; + parseErrors++; if (type == PARSE_WARNING && !fatal_warning_error_printed) { Error("parsing warnings being treated as errors"); fatal_warning_error_printed = true; @@ -3250,7 +3250,7 @@ Parse_File(const char *name, int fd) FinishDependencyGroup(); - if (fatals != 0) { + if (parseErrors != 0) { (void)fflush(stdout); (void)fprintf(stderr, "%s: Fatal errors encountered -- cannot continue", @@ -3305,7 +3305,7 @@ Parse_MainName(GNodeList *mainList) } int -Parse_GetFatals(void) +Parse_NumErrors(void) { - return fatals; + return parseErrors; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 14 13:26:07 UTC 2021 Modified Files: src/usr.bin/make: arch.c Log Message: make: extract RanlibOODate into separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 src/usr.bin/make/arch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.200 src/usr.bin/make/arch.c:1.201 --- src/usr.bin/make/arch.c:1.200 Sun May 30 21:16:54 2021 +++ src/usr.bin/make/arch.c Sat Aug 14 13:26:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -988,6 +988,34 @@ Arch_FindLib(GNode *gn, SearchPath *path #endif } +static bool +RanlibOODate(const GNode *gn MAKE_ATTR_UNUSED) +{ +#ifdef RANLIBMAG + struct ar_hdr *arh; /* Header for __.SYMDEF */ + int tocModTime; /* The table-of-contents' mod time */ + + arh = ArchStatMember(gn->path, RANLIBMAG, false); + + if (arh == NULL) { + /* A library without a table of contents is out-of-date. */ + if (DEBUG(ARCH) || DEBUG(MAKE)) + debug_printf("no toc..."); + return true; + } + + tocModTime = (int)strtol(arh->ar_date, NULL, 10); + + if (DEBUG(ARCH) || DEBUG(MAKE)) + debug_printf("%s modified %s...", + RANLIBMAG, Targ_FmtTime(tocModTime)); + return gn->youngestChild == NULL || + gn->youngestChild->mtime > tocModTime; +#else + return false; +#endif +} + /* * Decide if a node with the OP_LIB attribute is out-of-date. Called from * GNode_IsOODate to make its life easier. @@ -1021,46 +1049,19 @@ Arch_FindLib(GNode *gn, SearchPath *path bool Arch_LibOODate(GNode *gn) { - bool oodate; if (gn->type & OP_PHONY) { - oodate = true; + return true; } else if (!GNode_IsTarget(gn) && Lst_IsEmpty(>children)) { - oodate = false; + return false; } else if ((!Lst_IsEmpty(>children) && gn->youngestChild == NULL) || (gn->mtime > now) || (gn->youngestChild != NULL && gn->mtime < gn->youngestChild->mtime)) { - oodate = true; + return true; } else { -#ifdef RANLIBMAG - struct ar_hdr *arh; /* Header for __.SYMDEF */ - int modTimeTOC; /* The table-of-contents' mod time */ - - arh = ArchStatMember(gn->path, RANLIBMAG, false); - - if (arh != NULL) { - modTimeTOC = (int)strtol(arh->ar_date, NULL, 10); - - if (DEBUG(ARCH) || DEBUG(MAKE)) -debug_printf("%s modified %s...", - RANLIBMAG, - Targ_FmtTime(modTimeTOC)); - oodate = gn->youngestChild == NULL || - gn->youngestChild->mtime > modTimeTOC; - } else { - /* - * A library without a table of contents is out-of-date. - */ - if (DEBUG(ARCH) || DEBUG(MAKE)) -debug_printf("no toc..."); - oodate = true; - } -#else - oodate = false; -#endif + return RanlibOODate(gn); } - return oodate; } /* Initialize the archives module. */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 14 13:11:33 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: remove workaround for initialization bug in lint The bug has been fixed in init.c 1.208 from 2021-08-14. To generate a diff of this commit: cvs rdiff -u -r1.946 -r1.947 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.946 src/usr.bin/make/var.c:1.947 --- src/usr.bin/make/var.c:1.946 Sun Aug 8 12:00:30 2021 +++ src/usr.bin/make/var.c Sat Aug 14 13:11:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $ */ +/* $NetBSD: var.c,v 1.947 2021/08/14 13:11:33 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.947 2021/08/14 13:11:33 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4019,8 +4019,6 @@ ApplyModifiers( char endc /* ')' or '}'; or '\0' for indirect modifiers */ ) { - /* LINTED 115 *//* warning: left operand of '=' must be modifiable lvalue */ - /* That's a bug in lint; see tests/usr.bin/xlint/lint1/msg_115.c. */ ModChain ch = ModChain_Literal(expr, startc, endc, ' ', false); const char *p; const char *mod;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 14 13:04:00 UTC 2021 Modified Files: src/usr.bin/make: meta.c Log Message: make: fix lint warning about strchr removing 'const' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/usr.bin/make/meta.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.181 src/usr.bin/make/meta.c:1.182 --- src/usr.bin/make/meta.c:1.181 Sun Apr 4 10:05:08 2021 +++ src/usr.bin/make/meta.c Sat Aug 14 13:04:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.181 2021/04/04 10:05:08 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.182 2021/08/14 13:04:00 rillig Exp $ */ /* * Implement 'meta' mode. @@ -321,8 +321,7 @@ is_submake(const char *cmd, GNode *gn) static const char *p_make = NULL; static size_t p_len; char *mp = NULL; -char *cp; -char *cp2; +const char *cp, *cp2; bool rc = false; if (p_make == NULL) {
CVS commit: src/usr.bin/mkdep
Module Name:src Committed By: rillig Date: Wed Aug 11 20:48:16 UTC 2021 Modified Files: src/usr.bin/mkdep: findcc.c Log Message: mkdep: document possible undefined behavior If findcc is called with a constant string, as its prototype suggests, the process crashes with a segmentation fault. Luckily, neither mkdep nor lint do that, but the function prototype is nevertheless confusing. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/mkdep/findcc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/mkdep/findcc.c diff -u src/usr.bin/mkdep/findcc.c:1.6 src/usr.bin/mkdep/findcc.c:1.7 --- src/usr.bin/mkdep/findcc.c:1.6 Sun Sep 4 20:30:06 2011 +++ src/usr.bin/mkdep/findcc.c Wed Aug 11 20:48:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $ */ +/* $NetBSD: findcc.c,v 1.7 2021/08/11 20:48:16 rillig 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: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $"); +__RCSID("$NetBSD: findcc.c,v 1.7 2021/08/11 20:48:16 rillig Exp $"); #endif /* not lint */ #include @@ -55,6 +55,11 @@ findcc(const char *progname) char buffer[MAXPATHLEN]; if ((next = strchr(progname, ' ')) != NULL) { + /* + * FIXME: writing to a 'const char *' invokes undefined + * behavior. The call to 'strchr' subtly hides the unconst + * cast from the compiler. + */ *next = '\0'; }
CVS commit: src/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Wed Aug 11 05:37:45 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: main2.c Log Message: lint: add reminder to sort the output of lint2 To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/lint2/main2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint2/main2.c diff -u src/usr.bin/xlint/lint2/main2.c:1.17 src/usr.bin/xlint/lint2/main2.c:1.18 --- src/usr.bin/xlint/lint2/main2.c:1.17 Sun Apr 18 22:51:24 2021 +++ src/usr.bin/xlint/lint2/main2.c Wed Aug 11 05:37:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main2.c,v 1.17 2021/04/18 22:51:24 rillig Exp $ */ +/* $NetBSD: main2.c,v 1.18 2021/08/11 05:37:45 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main2.c,v 1.17 2021/04/18 22:51:24 rillig Exp $"); +__RCSID("$NetBSD: main2.c,v 1.18 2021/08/11 05:37:45 rillig Exp $"); #endif #include @@ -181,6 +181,7 @@ main(int argc, char *argv[]) mainused(); /* perform all tests */ + /* TODO: sort the names; hashcode order looks chaotic. */ forall(chkname); exit(0);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 10 19:52:14 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: remove redundant test for negative bit-field size A bit-field can never have negative size. Its type is an unsigned integer. Strangely, GCC 10.3.0 only complains about this if the extra struct level lint1_type.t_b is removed. Clang 12.0.1 does not complain at all. To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 src/usr.bin/xlint/lint1/decl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.219 src/usr.bin/xlint/lint1/decl.c:1.220 --- src/usr.bin/xlint/lint1/decl.c:1.219 Tue Aug 3 21:18:24 2021 +++ src/usr.bin/xlint/lint1/decl.c Tue Aug 10 19:52:14 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.220 2021/08/10 19:52:14 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.220 2021/08/10 19:52:14 rillig Exp $"); #endif #include @@ -1151,7 +1151,7 @@ declare_bit_field(sym_t *dsym, tspec_t * type_t *const tp = *inout_tp; tspec_t const t = *inout_t; - if (tp->t_flen < 0 || tp->t_flen > (ssize_t)size_in_bits(t)) { + if (tp->t_flen > size_in_bits(t)) { /* illegal bit-field size: %d */ error(36, tp->t_flen); tp->t_flen = size_in_bits(t);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 10 17:57:16 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: mem1.c Log Message: lint: remove redundant function prototypes To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/xlint/lint1/mem1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.48 src/usr.bin/xlint/lint1/mem1.c:1.49 --- src/usr.bin/xlint/lint1/mem1.c:1.48 Tue Aug 10 17:31:44 2021 +++ src/usr.bin/xlint/lint1/mem1.c Tue Aug 10 17:57:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.49 2021/08/10 17:57:16 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.49 2021/08/10 17:57:16 rillig Exp $"); #endif #include @@ -205,9 +205,6 @@ static memory_block *frmblks; /* length of new allocated memory blocks */ static size_t mblklen; -static void *xgetblk(memory_block **, size_t); -static void xfreeblk(memory_block **); -static memory_block *xnewblk(void); static memory_block * xnewblk(void)
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Tue Aug 10 17:31:44 UTC 2021 Modified Files: src/usr.bin/xlint/common: lint.h src/usr.bin/xlint/lint1: mem1.c src/usr.bin/xlint/lint2: externs2.h Log Message: lint: clean up comments To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint2/externs2.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.27 src/usr.bin/xlint/common/lint.h:1.28 --- src/usr.bin/xlint/common/lint.h:1.27 Sat Apr 10 18:36:27 2021 +++ src/usr.bin/xlint/common/lint.h Tue Aug 10 17:31:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.27 2021/04/10 18:36:27 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.28 2021/08/10 17:31:44 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -80,7 +80,7 @@ typedef enum { PTR, /* pointer */ ARRAY, /* array */ FUNC, /* function */ - COMPLEX, /* _Complex */ + COMPLEX, /* keyword "_Complex", only used in the parser */ FCOMPLEX, /* float _Complex */ DCOMPLEX, /* double _Complex */ LCOMPLEX /* long double _Complex */ Index: src/usr.bin/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.47 src/usr.bin/xlint/lint1/mem1.c:1.48 --- src/usr.bin/xlint/lint1/mem1.c:1.47 Sun Aug 1 18:07:35 2021 +++ src/usr.bin/xlint/lint1/mem1.c Tue Aug 10 17:31:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $"); #endif #include @@ -297,7 +297,7 @@ initmem(void) } -/* Allocate memory associated with level l. */ +/* Allocate memory associated with level l, initialized with zero. */ void * getlblk(size_t l, size_t s) { @@ -310,6 +310,10 @@ getlblk(size_t l, size_t s) return xgetblk([l], s); } +/* + * Return allocated memory for the current mem_block_level, initialized with + * zero. + */ void * getblk(size_t s) { Index: src/usr.bin/xlint/lint2/externs2.h diff -u src/usr.bin/xlint/lint2/externs2.h:1.9 src/usr.bin/xlint/lint2/externs2.h:1.10 --- src/usr.bin/xlint/lint2/externs2.h:1.9 Sat Jan 16 02:40:02 2021 +++ src/usr.bin/xlint/lint2/externs2.h Tue Aug 10 17:31:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs2.h,v 1.9 2021/01/16 02:40:02 rillig Exp $ */ +/* $NetBSD: externs2.h,v 1.10 2021/08/10 17:31:44 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -33,7 +33,7 @@ */ /* - * main.c + * main2.c */ extern bool xflag; extern bool uflag;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 10 16:59:28 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: ops.def Log Message: lint: fix documentation of FARG and PUSH To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/lint1/ops.def Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/ops.def diff -u src/usr.bin/xlint/lint1/ops.def:1.22 src/usr.bin/xlint/lint1/ops.def:1.23 --- src/usr.bin/xlint/lint1/ops.def:1.22 Tue Aug 10 07:02:00 2021 +++ src/usr.bin/xlint/lint1/ops.def Tue Aug 10 16:59:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.def,v 1.22 2021/08/10 07:02:00 rillig Exp $ */ +/* $NetBSD: ops.def,v 1.23 2021/08/10 16:59:28 rillig Exp $ */ begin_ops() @@ -93,6 +93,12 @@ op( COMMA, ",", 1,-,1,-,-,-,-,-,-,-,-,- op( CVT, "convert", -,-,-,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-) op( ICALL, "icall", 1,-,-,-,-,-,-,-,-,-,-,-,1,-,-,-,-,-,-,-) op( LOAD, "load", -,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-) +/* + * PUSH is a virtual node that is used to concatenate arguments in a function + * call expression. The PUSH nodes are ordered from right to left. For + * example, the function call f(17, 23) is represented as + * CALL(f, PUSH(23, PUSH(17, NULL))). + */ op( PUSH, "push", -,-,-,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-) op( RETURN, "return", 1,-,1,-,-,-,-,-,-,-,-,-,1,-,-,-,-,1,-,-) op( REAL, "real", -,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-) @@ -102,17 +108,11 @@ op( IMAG, "imag", -,-,-,-,-,-,-,-,-,-,- /* name repr b l b B i c a s f v t b s l r p c e e = */ op( INIT, "init", 1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-) op( CASE, "case", -,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-) -op( FARG, "farg", 1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-) - /* - * Both FARG and PUSH represent function arguments. FARG is used in the - * early phase of analysis, when the node is not yet part of a function call - * expression (CALL or ICALL). Later, build_function_argument builds a - * function call expression out of the FARG nodes, where they become PUSH. - * In a function call expression, the PUSH nodes are ordered from right to - * left, that is, the function call f(17, 23) is represented as - * CALL(f, PUSH(23, PUSH(17, NULL))). + * FARG is only used temporarily in check_prototype_argument to check type + * compatibility and conversion for function arguments. */ +op( FARG, "farg", 1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-) end_ops()
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 10 07:02:00 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: ops.def Log Message: lint: document the difference between FARG and PUSH To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/lint1/ops.def Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/ops.def diff -u src/usr.bin/xlint/lint1/ops.def:1.21 src/usr.bin/xlint/lint1/ops.def:1.22 --- src/usr.bin/xlint/lint1/ops.def:1.21 Tue Aug 10 06:31:16 2021 +++ src/usr.bin/xlint/lint1/ops.def Tue Aug 10 07:02:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.def,v 1.21 2021/08/10 06:31:16 rillig Exp $ */ +/* $NetBSD: ops.def,v 1.22 2021/08/10 07:02:00 rillig Exp $ */ begin_ops() @@ -104,6 +104,16 @@ op( INIT, "init", 1,-,1,-,-,-,-,-,-,-,- op( CASE, "case", -,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-) op( FARG, "farg", 1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-) +/* + * Both FARG and PUSH represent function arguments. FARG is used in the + * early phase of analysis, when the node is not yet part of a function call + * expression (CALL or ICALL). Later, build_function_argument builds a + * function call expression out of the FARG nodes, where they become PUSH. + * In a function call expression, the PUSH nodes are ordered from right to + * left, that is, the function call f(17, 23) is represented as + * CALL(f, PUSH(23, PUSH(17, NULL))). + */ + end_ops() #ifndef NOPS
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Aug 10 06:31:16 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: ops.def Log Message: lint: document operator properties directly at the definition To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/xlint/lint1/ops.def Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/ops.def diff -u src/usr.bin/xlint/lint1/ops.def:1.20 src/usr.bin/xlint/lint1/ops.def:1.21 --- src/usr.bin/xlint/lint1/ops.def:1.20 Thu Apr 1 14:59:21 2021 +++ src/usr.bin/xlint/lint1/ops.def Tue Aug 10 06:31:16 2021 @@ -1,9 +1,31 @@ -/* $NetBSD: ops.def,v 1.20 2021/04/01 14:59:21 rillig Exp $ */ +/* $NetBSD: ops.def,v 1.21 2021/08/10 06:31:16 rillig Exp $ */ begin_ops() -/* See mod_t in op.h for the definition of the table columns. */ - +/* + * Operator properties; see mod_t in op.h. + * + * warn if operand '=' x + * bad on enum x + * valid on enum x + * comparison - - - - - - - - - - - - - - - - x + * possible precedence confusion x | + * warn if right operand unsigned x | + * warn if left operand unsigned x | + * has side effects - - - - - - - - - - - - x | + * balance operands x | | + * left test context x | | + * left value context x | | + * fold constant operands - - - - - - - - x | | + * requires scalar x | | | + * requires arithmetic x | | | + * requires integer or complex x | | | + * requires integer - - - - x | | | + * requires _Bool x | | | | + * takes _Bool x | | | | + * logical x | | | | + * binary x | | | | + */ /* name repr b l b B i c a s f v t b s l r p c e e = */ op( NOOP, "no-op", -,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-) op( ARROW, "->", 1,-,1,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-)
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Mon Aug 9 21:27:20 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: remove commented-out preprocessor options These have been commented out since 2002. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.71 src/usr.bin/xlint/xlint/xlint.c:1.72 --- src/usr.bin/xlint/xlint/xlint.c:1.71 Sun Aug 8 16:19:18 2021 +++ src/usr.bin/xlint/xlint/xlint.c Mon Aug 9 21:27:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.72 2021/08/09 21:27:20 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.72 2021/08/09 21:27:20 rillig Exp $"); #endif #include @@ -341,18 +341,10 @@ main(int argc, char *argv[]) pass_to_cpp("-E"); pass_to_cpp("-x"); pass_to_cpp("c"); -#if 0 - pass_to_cpp("-D__attribute__(x)="); - pass_to_cpp("-D__extension__(x)=/*NOSTRICT*/0"); -#else pass_to_cpp("-U__GNUC__"); pass_to_cpp("-U__PCC__"); pass_to_cpp("-U__SSE__"); pass_to_cpp("-U__SSE4_1__"); -#endif -#if 0 - pass_to_cpp("-Wp,-$"); -#endif pass_to_cpp("-Wp,-CC"); pass_to_cpp("-Wcomment"); pass_to_cpp("-D__LINT__");
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Mon Aug 9 20:52:24 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: pathnames.h Log Message: lint: remove unused pathname To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/xlint/pathnames.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/pathnames.h diff -u src/usr.bin/xlint/xlint/pathnames.h:1.6 src/usr.bin/xlint/xlint/pathnames.h:1.7 --- src/usr.bin/xlint/xlint/pathnames.h:1.6 Sun Jan 24 16:55:09 2021 +++ src/usr.bin/xlint/xlint/pathnames.h Mon Aug 9 20:52:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pathnames.h,v 1.6 2021/01/24 16:55:09 rillig Exp $ */ +/* $NetBSD: pathnames.h,v 1.7 2021/08/09 20:52:24 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -36,9 +36,6 @@ #define PATH_LIBEXEC "/usr/libexec" #endif -/* directory where cc(1) resides */ -#define PATH_USRBIN "/usr/bin" - /* default library search path */ #ifndef PATH_LINTLIB #define PATH_LINTLIB "/usr/libdata/lint"
CVS commit: src/usr.bin/progress
Module Name:src Committed By: gson Date: Mon Aug 9 10:46:39 UTC 2021 Modified Files: src/usr.bin/progress: progress.c Log Message: Test errno when the return value from wait() indicates an error, not when it indicates success. PR install/56303. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/progress/progress.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/progress/progress.c diff -u src/usr.bin/progress/progress.c:1.23 src/usr.bin/progress/progress.c:1.24 --- src/usr.bin/progress/progress.c:1.23 Thu Jan 7 12:02:52 2021 +++ src/usr.bin/progress/progress.c Mon Aug 9 10:46:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.23 2021/01/07 12:02:52 lukem Exp $ */ +/* $NetBSD: progress.c,v 1.24 2021/08/09 10:46:39 gson Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progress.c,v 1.23 2021/01/07 12:02:52 lukem Exp $"); +__RCSID("$NetBSD: progress.c,v 1.24 2021/08/09 10:46:39 gson Exp $"); #endif/* not lint */ #include @@ -259,7 +259,7 @@ main(int argc, char *argv[]) */ ws = WIFSIGNALED(ws) ? WTERMSIG(ws) : WEXITSTATUS(ws); - if (deadpid != -1 && errno == EINTR) + if (deadpid == -1 && errno == EINTR) continue; if (deadpid == pid) { pid = 0;
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: wiz Date: Sun Aug 8 16:53:54 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: lint.1 Log Message: Fix Dd argument. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/xlint/lint.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/lint.1 diff -u src/usr.bin/xlint/xlint/lint.1:1.46 src/usr.bin/xlint/xlint/lint.1:1.47 --- src/usr.bin/xlint/xlint/lint.1:1.46 Sun Aug 8 15:59:32 2021 +++ src/usr.bin/xlint/xlint/lint.1 Sun Aug 8 16:53:53 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: lint.1,v 1.46 2021/08/08 15:59:32 rillig Exp $ +.\" $NetBSD: lint.1,v 1.47 2021/08/08 16:53:53 wiz Exp $ .\" .\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. .\" Copyright (c) 1994, 1995 Jochen Pohl @@ -30,7 +30,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd Aug 08, 2021 +.Dd August 8, 2021 .Dt LINT 1 .Os .Sh NAME
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 16:19:18 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: group global variables by the subprocess No functional change. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.70 src/usr.bin/xlint/xlint/xlint.c:1.71 --- src/usr.bin/xlint/xlint/xlint.c:1.70 Sun Aug 8 16:11:08 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 8 16:19:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $"); #endif #include @@ -61,38 +61,30 @@ __RCSID("$NetBSD: xlint.c,v 1.70 2021/08 #define DEFAULT_PATH _PATH_DEFPATH -/* directory for temporary files */ -static const char *tmpdir; - -/* path name for cpp output */ -static char *cppout; - -/* file descriptor for cpp output */ -static int cppoutfd = -1; - -/* files created by 1st pass */ -static char **p1out; - -/* input files for 2nd pass (without libraries) */ -static char **p2in; - -/* library which will be created by 2nd pass */ -static char *p2out; +/* Parameters for the C preprocessor. */ +static struct { + char **flags; /* flags always passed */ + char **lcflags; /* flags, controlled by sflag/tflag */ + char *outfile; /* path name for preprocessed C source */ + int outfd; /* file descriptor for outfile */ +} cpp = { NULL, NULL, NULL, -1 }; + +/* Parameters for lint1, which checks an isolated translation unit. */ +static struct { + char **flags; + char **outfiles; +} lint1; + +/* Parameters for lint2, which performs cross-translation-unit checks. */ +static struct { + char **flags; + char **infiles; /* input files (without libraries) */ + char **inlibs; /* input libraries */ + char *outlib; /* output library that will be created */ +} lint2; -/* flags always passed to cc(1) */ -static char **cflags; - -/* flags for cc(1), controlled by sflag/tflag */ -static char **lcflags; - -/* flags for lint1 */ -static char **l1flags; - -/* flags for lint2 */ -static char **l2flags; - -/* libraries for lint2 */ -static char **l2libs; +/* directory for temporary files */ +static const char *tmpdir; /* default libraries */ static char **deflibs; @@ -136,7 +128,7 @@ static void fname(const char *); static void runchild(const char *, char *const *, const char *, int); static void findlibs(char *const *); static bool rdok(const char *); -static void lint2(void); +static void run_lint2(void); static void cat(char *const *, const char *); static char ** @@ -207,21 +199,21 @@ static void pass_to_lint1(const char *opt) { - list_add_copy(, opt); + list_add_copy(, opt); } static void pass_to_lint2(const char *opt) { - list_add_copy(, opt); + list_add_copy(, opt); } static void pass_to_cpp(const char *opt) { - list_add_copy(, opt); + list_add_copy(, opt); } static char * @@ -244,23 +236,23 @@ terminate(int signo) { int i; - if (cppoutfd != -1) - (void)close(cppoutfd); - if (cppout != NULL) { + if (cpp.outfd != -1) + (void)close(cpp.outfd); + if (cpp.outfile != NULL) { if (signo != 0 && getenv("LINT_KEEP_CPPOUT_ON_ERROR") != NULL) printf("lint: preprocessor output kept in %s\n", - cppout); + cpp.outfile); else - (void)remove(cppout); + (void)remove(cpp.outfile); } - if (p1out != NULL) { - for (i = 0; p1out[i] != NULL; i++) - (void)remove(p1out[i]); + if (lint1.outfiles != NULL) { + for (i = 0; lint1.outfiles[i] != NULL; i++) + (void)remove(lint1.outfiles[i]); } - if (p2out != NULL) - (void)remove(p2out); + if (lint2.outlib != NULL) + (void)remove(lint2.outlib); if (currfn != NULL) (void)remove(currfn); @@ -328,20 +320,20 @@ main(int argc, char *argv[]) tmpdir = concat2(tmp, tmp[len - 1] == '/' ? "" : "/"); } - cppout = concat2(tmpdir, "lint0.XX"); - cppoutfd = mkstemp(cppout); - if (cppoutfd == -1) { + cpp.outfile = concat2(tmpdir, "lint0.XX"); + cpp.outfd = mkstemp(cpp.outfile); + if (cpp.outfd == -1) { warn("can't make temp"); terminate(-1); } - p1out = list_new(); - p2in = list_new(); - cflags = list_new(); - lcflags = list_new(); - l1flags = list_new(); - l2flags = list_new(); - l2libs = list_new(); + lint1.outfiles = list_new(); + lint2.infiles = list_new(); + cpp.flags = list_new(); + cpp.lcflags = list_new(); + lint1.flags = list_new(); + lint2.flags = list_new(); + lint2.inlibs = list_new(); deflibs = list_new(); libs =
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 16:11:08 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: rename list_free to list_clear The previous name suggested that the function would free the list itself, which it doesn't. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.69 src/usr.bin/xlint/xlint/xlint.c:1.70 --- src/usr.bin/xlint/xlint/xlint.c:1.69 Sun Aug 8 15:29:24 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 8 16:11:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $"); #endif #include @@ -189,7 +189,7 @@ list_add_all(char ***destp, char *const } static void -list_free(char ***lstp) +list_clear(char ***lstp) { char *s; int i; @@ -420,14 +420,14 @@ main(int argc, char *argv[]) break; case 'n': - list_free(); + list_clear(); break; case 'p': pass_to_lint1("-p"); pass_to_lint2("-p"); if (*deflibs != NULL) { -list_free(); +list_clear(); list_add_copy(, "c"); } break; @@ -443,7 +443,7 @@ main(int argc, char *argv[]) case 's': if (tflag) usage(); - list_free(); + list_clear(); list_add_copy(, "-trigraphs"); list_add_copy(, "-Wtrigraphs"); list_add_copy(, "-pedantic"); @@ -471,7 +471,7 @@ main(int argc, char *argv[]) case 't': if (sflag) usage(); - list_free(); + list_clear(); list_add_copy(, "-traditional"); list_add_copy(, "-Wtraditional"); list_add(, concat2("-D", MACHINE)); @@ -492,7 +492,7 @@ main(int argc, char *argv[]) Cflag = true; list_add(, concat2("-C", optarg)); p2out = xasprintf("llib-l%s.ln", optarg); - list_free(); + list_clear(); break; case 'd': @@ -705,7 +705,7 @@ fname(const char *name) runchild(pathname, args, cppout, cppoutfd); free(pathname); - list_free(); + list_clear(); /* run lint1 */ @@ -727,7 +727,7 @@ fname(const char *name) runchild(pathname, args, ofn, -1); free(pathname); - list_free(); + list_clear(); list_add_copy(, ofn); free(ofn); @@ -864,7 +864,7 @@ lint2(void) runchild(path, args, p2out, -1); free(path); - list_free(); + list_clear(); free(args); }
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 15:59:32 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: lint.1 Log Message: lint: update and proofread manual page To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/xlint/lint.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/lint.1 diff -u src/usr.bin/xlint/xlint/lint.1:1.45 src/usr.bin/xlint/xlint/lint.1:1.46 --- src/usr.bin/xlint/xlint/lint.1:1.45 Sun Aug 8 15:29:24 2021 +++ src/usr.bin/xlint/xlint/lint.1 Sun Aug 8 15:59:32 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: lint.1,v 1.45 2021/08/08 15:29:24 rillig Exp $ +.\" $NetBSD: lint.1,v 1.46 2021/08/08 15:59:32 rillig Exp $ .\" .\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. .\" Copyright (c) 1994, 1995 Jochen Pohl @@ -30,7 +30,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd Apr 14, 2021 +.Dd Aug 08, 2021 .Dt LINT 1 .Os .Sh NAME @@ -40,7 +40,7 @@ .Nm .Op Fl abceFgHhPprTVvwxz .Op Fl i | Fl nu -.Op Fl S | Fl s | Fl t +.Op Fl S | Fl s | Fl t | Fl Ac11 .Op Fl B Ar directory .Op Fl D Ar name Ns Op =def .Op Fl d Ar directory @@ -51,12 +51,11 @@ .Op Fl o Ar outputfile .Op Fl U Ar name .Op Fl X Ar id Ns Op ,id ... -.Op Fl Ac11 .Op Fl Z Ar cpparg .Ar .Nm lint .Op Fl abceFgHhprTVvwz -.Op Fl S | Fl s | Fl t +.Op Fl S | Fl s | Fl t | Fl Ac11 .Fl C Ar library .Op Fl B Ar directory .Op Fl D Ar name Ns Op =def @@ -73,8 +72,8 @@ attempts to detect features of the named C program files that are likely to be bugs, to be non-portable, or to be wasteful. -It also performs stricter type checking than does the C compiler. -The list of errors +It also performs stricter type checking than traditional pre-C90 C compilers. +The list of errors and warnings that .Nm produces are enumerated in .Xr lint 7 . @@ -98,11 +97,11 @@ variables declared and not used, and log with constant values. Function calls are checked for inconsistencies, such as calls to functions that return -values in some places and not in others, functions called -with varying numbers of arguments, function calls that +values in some places and not in others, non-prototype functions called +with varying numbers of arguments, non-prototype function calls that pass arguments of a type other than the type the function -expects to receive, functions whose values are not used, -and calls to functions not returning values that use +expects to receive, functions whose return values are not used, +and calls to non-prototype functions not returning values that nevertheless use the non-existent return value of the function. .Pp Filename arguments ending with @@ -159,16 +158,17 @@ files are ignored. When the .Fl i option is -.Em omitted +.Em omitted , the second pass of .Nm -checks this list of files for mutual compatibility. +checks this list of files for mutual compatibility +but always exits successfully. At this point, if a complaint stems not from a given source file, but from one of its included files, the source filename will be printed followed by a question mark. .Pp .Sy Options -.Bl -tag -width XoXoutputfileXXX +.Bl -tag -width XXoutputfile .It Fl Ac11 Allow features from C11, C99 and C90. .It Fl a @@ -233,11 +233,10 @@ instead of as the default place to find include files. .It Fl e Complain about unusual operations on -.Sy enum Ns -Types +.Sy enum Ns types and combinations of -.Sy enum Ns - -and -.Sy integer Ns -Types . +.Sy enum +and integer types . .It Fl F Print pathnames of files. .Nm @@ -266,7 +265,7 @@ and .Sy inline are always available). .It Fl H -If a complaint stems from an included file +If a complaint stems from an included file, .Nm prints the name of the included file instead of the source file name followed by a question mark. @@ -302,7 +301,7 @@ Include the lint library Pass .Fl MD to -.Xr cpp 1 +.Xr cpp 1 , causing cpp to create files containing dependency information for each source file. .It Fl n @@ -318,7 +317,7 @@ The option simply saves this file in the named output file. If the .Fl i -option is also used the files are not checked for compatibility. +option is also used, the files are not checked for compatibility. To produce a .Pa llib-l Ns Ar library Ns Pa \&.ln without extraneous messages, use of the @@ -329,11 +328,11 @@ The option is useful if the source file(s) for the lint library are just external interfaces. .It Fl P -Enable more portability warnings: Enum comparisons, sign extension issues +Enable more portability warnings: enum comparisons, sign extension issues when assigning to wider integer types, overflow warnings when assigning to wider types. .It Fl p -Attempt to check portability of code to other dialects of C. +Attempt to check portability of
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 15:29:24 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: lint.1 xlint.c Log Message: lint: remove dead code for reading from stdin Since xlint.c 1.27 from 2002-01-31, it has not been possible to read from stdin anymore. Apparently nobody missed this feature in the last 19 years. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/usr.bin/xlint/xlint/lint.1 cvs rdiff -u -r1.68 -r1.69 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/lint.1 diff -u src/usr.bin/xlint/xlint/lint.1:1.44 src/usr.bin/xlint/xlint/lint.1:1.45 --- src/usr.bin/xlint/xlint/lint.1:1.44 Sun May 2 21:05:42 2021 +++ src/usr.bin/xlint/xlint/lint.1 Sun Aug 8 15:29:24 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: lint.1,v 1.44 2021/05/02 21:05:42 rillig Exp $ +.\" $NetBSD: lint.1,v 1.45 2021/08/08 15:29:24 rillig Exp $ .\" .\" Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. .\" Copyright (c) 1994, 1995 Jochen Pohl @@ -167,22 +167,6 @@ At this point, if a complaint stems not but from one of its included files, the source filename will be printed followed by a question mark. .Pp -The special input file name -.Dq Pa - -causes -.Nm -to take input from standard input (until end of file) and process -it as if it were a -.Pa \&.c -file. -If the -.Fl i -flag is given and -.Dq Pa - -is named as one of the input files, the -.Fl o -flag must also be specified to provide an output file name. -.Pp .Sy Options .Bl -tag -width XoXoutputfileXXX .It Fl Ac11 Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.68 src/usr.bin/xlint/xlint/xlint.c:1.69 --- src/usr.bin/xlint/xlint/xlint.c:1.68 Sun Aug 8 15:06:44 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 8 15:29:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $"); #endif #include @@ -634,10 +634,8 @@ fname(const char *name) char **args, *ofn, *pathname; const char *CC; size_t len; - bool is_stdin; int fd; - is_stdin = strcmp(name, "-") == 0; bn = lbasename(name, '/'); suff = lbasename(bn, '.'); @@ -648,15 +646,14 @@ fname(const char *name) return; } - if (!is_stdin && strcmp(suff, "c") != 0 && + if (strcmp(suff, "c") != 0 && (strncmp(bn, "llib-l", 6) != 0 || bn != suff)) { warnx("unknown file type: %s", name); return; } if (!iflag || !first) - (void)printf("%s:\n", - is_stdin ? "{standard input}" : Fflag ? name : bn); + (void)printf("%s:\n", Fflag ? name : bn); /* build the name of the output file of lint1 */ if (oflag) { @@ -664,10 +661,6 @@ fname(const char *name) outputfn = NULL; oflag = false; } else if (iflag) { - if (is_stdin) { - warnx("-i not supported without -o for standard input"); - return; - } len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn); ofn = xasprintf("%.*s.ln", (int)len, bn); } else {
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 15:06:44 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: inline list_add_defines No functional change. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.67 src/usr.bin/xlint/xlint/xlint.c:1.68 --- src/usr.bin/xlint/xlint/xlint.c:1.67 Sun Aug 8 15:03:47 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 8 15:06:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $"); #endif #include @@ -129,7 +129,6 @@ static const char *currfn; static const char target_prefix[] = TARGET_PREFIX; static char *concat2(const char *, const char *); -static char *concat3(const char *, const char *, const char *); static void terminate(int) __attribute__((__noreturn__)); static const char *lbasename(const char *, int); static void usage(void); @@ -190,14 +189,6 @@ list_add_all(char ***destp, char *const } static void -list_add_defines(char ***lstp, const char *def) -{ - - list_add(lstp, concat2("-D__", def)); - list_add(lstp, concat3("-D__", def, "__")); -} - -static void list_free(char ***lstp) { char *s; @@ -245,19 +236,6 @@ concat2(const char *s1, const char *s2) return s; } -static char * -concat3(const char *s1, const char *s2, const char *s3) -{ - char *s; - - s = xmalloc(strlen(s1) + strlen(s2) + strlen(s3) + 1); - (void)strcpy(s, s1); - (void)strcat(s, s2); - (void)strcat(s, s3); - - return s; -} - /* * Clean up after a signal. */ @@ -387,8 +365,8 @@ main(int argc, char *argv[]) pass_to_cpp("-Wcomment"); pass_to_cpp("-D__LINT__"); pass_to_cpp("-Dlint"); /* XXX don't def. with -s */ - - list_add_defines(, "lint"); + pass_to_cpp("-D__lint"); + pass_to_cpp("-D__lint__"); list_add_copy(, "c");
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 15:03:48 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: rename functions for handling string lists No functional change. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.66 src/usr.bin/xlint/xlint/xlint.c:1.67 --- src/usr.bin/xlint/xlint/xlint.c:1.66 Sun Aug 8 14:05:33 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 8 15:03:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $"); #endif #include @@ -128,15 +128,10 @@ static const char *currfn; #endif static const char target_prefix[] = TARGET_PREFIX; -static void appstrg(char ***, char *); -static void appcstrg(char ***, const char *); -static void applst(char ***, char *const *); -static void freelst(char ***); static char *concat2(const char *, const char *); static char *concat3(const char *, const char *, const char *); static void terminate(int) __attribute__((__noreturn__)); static const char *lbasename(const char *, int); -static void appdef(char ***, const char *); static void usage(void); static void fname(const char *); static void runchild(const char *, char *const *, const char *, int); @@ -145,12 +140,17 @@ static bool rdok(const char *); static void lint2(void); static void cat(char *const *, const char *); -/* - * Some functions to deal with lists of strings. - * Take care that we get no surprises in case of asynchronous signals. - */ +static char ** +list_new(void) +{ + char **list; + + list = xcalloc(1, sizeof(*list)); + return list; +} + static void -appstrg(char ***lstp, char *s) +list_add(char ***lstp, char *s) { char **lst, **olst; int i; @@ -165,14 +165,14 @@ appstrg(char ***lstp, char *s) } static void -appcstrg(char ***lstp, const char *s) +list_add_copy(char ***lstp, const char *s) { - appstrg(lstp, xstrdup(s)); + list_add(lstp, xstrdup(s)); } static void -applst(char ***destp, char *const *src) +list_add_all(char ***destp, char *const *src) { int i, k; char **dest, **odest; @@ -190,7 +190,15 @@ applst(char ***destp, char *const *src) } static void -freelst(char ***lstp) +list_add_defines(char ***lstp, const char *def) +{ + + list_add(lstp, concat2("-D__", def)); + list_add(lstp, concat3("-D__", def, "__")); +} + +static void +list_free(char ***lstp) { char *s; int i; @@ -208,21 +216,21 @@ static void pass_to_lint1(const char *opt) { - appcstrg(, opt); + list_add_copy(, opt); } static void pass_to_lint2(const char *opt) { - appcstrg(, opt); + list_add_copy(, opt); } static void pass_to_cpp(const char *opt) { - appcstrg(, opt); + list_add_copy(, opt); } static char * @@ -303,14 +311,6 @@ lbasename(const char *strg, int delim) return *cp1 == '\0' ? cp2 : cp1; } -static void -appdef(char ***lstp, const char *def) -{ - - appstrg(lstp, concat2("-D__", def)); - appstrg(lstp, concat3("-D__", def, "__")); -} - static void __attribute__((noreturn)) usage(void) { @@ -357,16 +357,16 @@ main(int argc, char *argv[]) terminate(-1); } - p1out = xcalloc(1, sizeof(*p1out)); - p2in = xcalloc(1, sizeof(*p2in)); - cflags = xcalloc(1, sizeof(*cflags)); - lcflags = xcalloc(1, sizeof(*lcflags)); - l1flags = xcalloc(1, sizeof(*l1flags)); - l2flags = xcalloc(1, sizeof(*l2flags)); - l2libs = xcalloc(1, sizeof(*l2libs)); - deflibs = xcalloc(1, sizeof(*deflibs)); - libs = xcalloc(1, sizeof(*libs)); - libsrchpath = xcalloc(1, sizeof(*libsrchpath)); + p1out = list_new(); + p2in = list_new(); + cflags = list_new(); + lcflags = list_new(); + l1flags = list_new(); + l2flags = list_new(); + l2libs = list_new(); + deflibs = list_new(); + libs = list_new(); + libsrchpath = list_new(); pass_to_cpp("-E"); pass_to_cpp("-x"); @@ -388,9 +388,9 @@ main(int argc, char *argv[]) pass_to_cpp("-D__LINT__"); pass_to_cpp("-Dlint"); /* XXX don't def. with -s */ - appdef(, "lint"); + list_add_defines(, "lint"); - appcstrg(, "c"); + list_add_copy(, "c"); if (signal(SIGHUP, terminate) == SIG_IGN) (void)signal(SIGHUP, SIG_IGN); @@ -442,15 +442,15 @@ main(int argc, char *argv[]) break; case 'n': - freelst(); + list_free(); break; case 'p': pass_to_lint1("-p"); pass_to_lint2("-p"); if (*deflibs != NULL) { -freelst(); -appcstrg(, "c"); +list_free(); +list_add_copy(, "c"); }
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 14:05:33 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: make data flow in findlibs simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.65 src/usr.bin/xlint/xlint/xlint.c:1.66 --- src/usr.bin/xlint/xlint/xlint.c:1.65 Sun Aug 8 13:34:57 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 8 14:05:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $"); #endif #include @@ -821,37 +821,40 @@ runchild(const char *path, char *const * } static void -findlibs(char *const *liblst) +findlib(const char *lib) { - int i, k; - const char *lib, *path; - char *lfn; - size_t len; + char *const *dir; + char *lfn; - lfn = NULL; + for (dir = libsrchpath; *dir != NULL; dir++) { + lfn = xasprintf("%s/llib-l%s.ln", *dir, lib); + if (rdok(lfn)) + goto found; + free(lfn); - for (i = 0; (lib = liblst[i]) != NULL; i++) { - for (k = 0; (path = libsrchpath[k]) != NULL; k++) { - len = strlen(path) + strlen(lib); - lfn = xrealloc(lfn, len + sizeof("/llib-l.ln")); - (void)sprintf(lfn, "%s/llib-l%s.ln", path, lib); - if (rdok(lfn)) -break; - lfn = xrealloc(lfn, len + sizeof("/lint/llib-l.ln")); - (void)sprintf(lfn, "%s/lint/llib-l%s.ln", path, lib); - if (rdok(lfn)) -break; - } - if (path != NULL) { - appstrg(, concat2("-l", lfn)); - } else { - warnx("cannot find llib-l%s.ln", lib); - } + lfn = xasprintf("%s/lint/llib-l%s.ln", *dir, lib); + if (rdok(lfn)) + goto found; + free(lfn); } + warnx("cannot find llib-l%s.ln", lib); + return; + +found: + appstrg(, concat2("-l", lfn)); free(lfn); } +static void +findlibs(char *const *liblst) +{ + char *const *p; + + for (p = liblst; *p != NULL; p++) + findlib(*p); +} + static bool rdok(const char *path) {
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Sun Aug 8 13:34:57 UTC 2021 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: make memory management in xlint simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.64 src/usr.bin/xlint/xlint/xlint.c:1.65 --- src/usr.bin/xlint/xlint/xlint.c:1.64 Sun Aug 1 18:13:53 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 8 13:34:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $"); #endif #include @@ -347,13 +347,10 @@ main(int argc, char *argv[]) if ((tmp = getenv("TMPDIR")) == NULL || (len = strlen(tmp)) == 0) { tmpdir = xstrdup(_PATH_TMP); } else { - char *p = xmalloc(len + 2); - (void)sprintf(p, "%s%s", tmp, tmp[len - 1] == '/' ? "" : "/"); - tmpdir = p; + tmpdir = concat2(tmp, tmp[len - 1] == '/' ? "" : "/"); } - cppout = xmalloc(strlen(tmpdir) + sizeof("lint0.XX")); - (void)sprintf(cppout, "%slint0.XX", tmpdir); + cppout = concat2(tmpdir, "lint0.XX"); cppoutfd = mkstemp(cppout); if (cppoutfd == -1) { warn("can't make temp"); @@ -516,8 +513,7 @@ main(int argc, char *argv[]) usage(); Cflag = true; appstrg(, concat2("-C", optarg)); - p2out = xmalloc(sizeof("llib-l.ln") + strlen(optarg)); - (void)sprintf(p2out, "llib-l%s.ln", optarg); + p2out = xasprintf("llib-l%s.ln", optarg); freelst(); break; @@ -534,8 +530,7 @@ main(int argc, char *argv[]) case 'I': case 'M': case 'U': - (void)sprintf(flgbuf, "-%c", c); - appstrg(, concat2(flgbuf, optarg)); + appstrg(, xasprintf("-%c%s", c, optarg)); break; case 'l': @@ -744,17 +739,14 @@ fname(const char *name) /* run lint1 */ if (!Bflag) { - pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof("/lint1") + - strlen(target_prefix)); - (void)sprintf(pathname, "%s/%slint1", PATH_LIBEXEC, - target_prefix); + pathname = xasprintf("%s/%slint1", + PATH_LIBEXEC, target_prefix); } else { /* * XXX Unclear whether we should be using target_prefix * XXX here. --thor...@wasabisystems.com */ - pathname = xmalloc(strlen(libexec_path) + sizeof("/lint1")); - (void)sprintf(pathname, "%s/lint1", libexec_path); + pathname = concat2(libexec_path, "/lint1"); } appcstrg(, pathname); @@ -882,17 +874,13 @@ lint2(void) args = xcalloc(1, sizeof(*args)); if (!Bflag) { - path = xmalloc(strlen(PATH_LIBEXEC) + sizeof("/lint2") + - strlen(target_prefix)); - (void)sprintf(path, "%s/%slint2", PATH_LIBEXEC, - target_prefix); + path = xasprintf("%s/%slint2", PATH_LIBEXEC, target_prefix); } else { /* * XXX Unclear whether we should be using target_prefix * XXX here. --thor...@wasabisystems.com */ - path = xmalloc(strlen(libexec_path) + sizeof("/lint2")); - (void)sprintf(path, "%s/lint2", libexec_path); + path = concat2(libexec_path, "/lint2"); } appcstrg(, path);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Aug 8 12:00:30 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: remove redundant initialization in ApplyModifier_Order No functional change. To generate a diff of this commit: cvs rdiff -u -r1.945 -r1.946 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.945 src/usr.bin/make/var.c:1.946 --- src/usr.bin/make/var.c:1.945 Sat Jul 31 09:30:17 2021 +++ src/usr.bin/make/var.c Sun Aug 8 12:00:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $ */ +/* $NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3355,7 +3355,7 @@ ApplyModifier_Order(const char **pp, Mod { const char *mod = *pp; Words words; - int (*cmp)(const void *, const void *) = NULL; + int (*cmp)(const void *, const void *); if (IsDelimiter(mod[1], ch) || mod[1] == '\0') { cmp = str_cmp_asc;
CVS commit: src/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Sun Aug 8 11:56:36 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: Makefile chk.c read.c Log Message: lint: force strict bool mode No functional change. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/xlint/lint2/Makefile cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.48 -r1.49 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint2/Makefile diff -u src/usr.bin/xlint/lint2/Makefile:1.20 src/usr.bin/xlint/lint2/Makefile:1.21 --- src/usr.bin/xlint/lint2/Makefile:1.20 Sun Apr 18 22:51:24 2021 +++ src/usr.bin/xlint/lint2/Makefile Sun Aug 8 11:56:35 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.20 2021/04/18 22:51:24 rillig Exp $ +# $NetBSD: Makefile,v 1.21 2021/08/08 11:56:35 rillig Exp $ NOMAN= # defined @@ -7,6 +7,7 @@ SRCS= main2.c hash.c read.c mem.c mem2. inittyp.c tyname.c BINDIR= /usr/libexec CPPFLAGS+= -I${.CURDIR} +LINTFLAGS+= -T # strict bool mode COPTS.msg.c+= ${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :} Index: src/usr.bin/xlint/lint2/chk.c diff -u src/usr.bin/xlint/lint2/chk.c:1.42 src/usr.bin/xlint/lint2/chk.c:1.43 --- src/usr.bin/xlint/lint2/chk.c:1.42 Fri Apr 2 12:16:50 2021 +++ src/usr.bin/xlint/lint2/chk.c Sun Aug 8 11:56:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: chk.c,v 1.42 2021/04/02 12:16:50 rillig Exp $ */ +/* $NetBSD: chk.c,v 1.43 2021/08/08 11:56:35 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: chk.c,v 1.42 2021/04/02 12:16:50 rillig Exp $"); +__RCSID("$NetBSD: chk.c,v 1.43 2021/08/08 11:56:35 rillig Exp $"); #endif #include @@ -1085,9 +1085,9 @@ chkrvu(hte_t *hte, sym_t *def) * but for now I don't want to be bothered by this warnings * which are almost always useless. */ - if (hflag == 0) + if (!hflag) return; - if (hflag == 1 && bsearch(hte->h_name, ignorelist, + if (hflag && bsearch(hte->h_name, ignorelist, __arraycount(ignorelist), sizeof(ignorelist[0]), (int (*)(const void *, const void *))strcmp) != NULL) return; @@ -1340,7 +1340,7 @@ eqargs(type_t *tp1, type_t *tp2, bool *d while (*a1 != NULL && *a2 != NULL) { - if (eqtype(*a1, *a2, true, false, false, dowarn) == 0) + if (!eqtype(*a1, *a2, true, false, false, dowarn)) return false; a1++; Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.48 src/usr.bin/xlint/lint2/read.c:1.49 --- src/usr.bin/xlint/lint2/read.c:1.48 Thu Aug 5 06:54:16 2021 +++ src/usr.bin/xlint/lint2/read.c Sun Aug 8 11:56:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $ */ +/* $NetBSD: read.c,v 1.49 2021/08/08 11:56:35 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.49 2021/08/08 11:56:35 rillig Exp $"); #endif #include @@ -402,7 +402,7 @@ decldef(pos_t *posp, const char *cp) sym.s_def = DECL; break; case 'i': - if (sym.s_inline != NODECL) + if (sym.s_inline) inperr("inline %c", c); sym.s_inline = true; break;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 8 10:41:34 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: emit1.c Log Message: lint: condense code for writing the .ln files No functional change. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/lint1/emit1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.47 src/usr.bin/xlint/lint1/emit1.c:1.48 --- src/usr.bin/xlint/lint1/emit1.c:1.47 Sat Jul 31 19:52:44 2021 +++ src/usr.bin/xlint/lint1/emit1.c Sun Aug 8 10:41:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.47 2021/07/31 19:52:44 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.48 2021/08/08 10:41:34 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit1.c,v 1.47 2021/07/31 19:52:44 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.48 2021/08/08 10:41:34 rillig Exp $"); #endif #include "lint1.h" @@ -227,26 +227,19 @@ outsym(const sym_t *sym, scl_t sc, def_t /* flags */ - switch (def) { - case DEF: - /* defined */ - outchar('d'); - break; - case TDEF: - /* tentative defined */ - outchar('t'); - break; - case DECL: - /* declared */ - outchar('e'); - break; - default: - lint_assert(/*CONSTCOND*/false); + if (def == DEF) + outchar('d'); /* defined */ + else if (def == TDEF) + outchar('t'); /* tentative defined */ + else { + lint_assert(def == DECL); + outchar('e'); /* declared */ } + if (llibflg && def != DECL) { /* - * mark it as used so we get no warnings from lint2 about - * unused symbols in libraries. + * mark it as used so lint2 does not complain about + * unused symbols in libraries */ outchar('u'); } @@ -327,8 +320,7 @@ outfdef(const sym_t *fsym, const pos_t * outchar('d'); if (rval) - /* has return value */ - outchar('r'); + outchar('r'); /* has return value */ if (llibflg) /* @@ -338,8 +330,7 @@ outfdef(const sym_t *fsym, const pos_t * outchar('u'); if (osdef) - /* old style function definition */ - outchar('o'); + outchar('o'); /* old style function definition */ if (fsym->s_inline) outchar('i');
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sat Aug 7 17:38:41 UTC 2021 Modified Files: src/usr.bin/xlint: Makefile.inc src/usr.bin/xlint/lint1: Makefile Log Message: lint: clean gcov files for lint2 and xlint as well To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/Makefile.inc cvs rdiff -u -r1.82 -r1.83 src/usr.bin/xlint/lint1/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/Makefile.inc diff -u src/usr.bin/xlint/Makefile.inc:1.14 src/usr.bin/xlint/Makefile.inc:1.15 --- src/usr.bin/xlint/Makefile.inc:1.14 Sun Apr 18 22:51:24 2021 +++ src/usr.bin/xlint/Makefile.inc Sat Aug 7 17:38:41 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.14 2021/04/18 22:51:24 rillig Exp $ +# $NetBSD: Makefile.inc,v 1.15 2021/08/07 17:38:41 rillig Exp $ .include @@ -17,6 +17,8 @@ ARCHSUBDIR= ${MACHINE_CPU} CPPFLAGS+= -I${.CURDIR}/../arch/${ARCHSUBDIR} CPPFLAGS+= -I${.CURDIR}/../common +CLEANFILES+= *.gcno *.gcda *.gcov + .if exists(${.CURDIR}/../../Makefile.inc) .include "${.CURDIR}/../../Makefile.inc" .endif Index: src/usr.bin/xlint/lint1/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.82 src/usr.bin/xlint/lint1/Makefile:1.83 --- src/usr.bin/xlint/lint1/Makefile:1.82 Sat Jul 31 18:16:42 2021 +++ src/usr.bin/xlint/lint1/Makefile Sat Aug 7 17:38:41 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.82 2021/07/31 18:16:42 rillig Exp $ +# $NetBSD: Makefile,v 1.83 2021/08/07 17:38:41 rillig Exp $ .include @@ -29,7 +29,6 @@ COPTS.err.c+= ${${ACTIVE_CC} == "clang": BINDIR= /usr/libexec CLEANFILES+= ${MAN} -CLEANFILES+= *.gcno *.gcda *.gcov .if ${USETOOLS} == "yes" LINT1= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1
CVS commit: src/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Thu Aug 5 06:54:16 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: read.c Log Message: lint: fix type of local variable in inpqstrg Noted by Clang-Tidy. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.47 src/usr.bin/xlint/lint2/read.c:1.48 --- src/usr.bin/xlint/lint2/read.c:1.47 Thu Aug 5 06:45:37 2021 +++ src/usr.bin/xlint/lint2/read.c Thu Aug 5 06:54:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $ */ +/* $NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $"); #endif #include @@ -1057,7 +1057,7 @@ inpqstrg(const char *src, const char **e { char *strg, *dst; size_t slen; - int c; + char c; int v; dst = strg = xmalloc(slen = 32); @@ -1110,7 +1110,7 @@ inpqstrg(const char *src, const char **e if ((c = *src++) < '0' || c > '7') inperr("not octal: %c", c); v |= c - '0'; -c = (u_char)v; +c = (char)v; break; default: inperr("bad \\ escape: %c", c); @@ -1122,7 +1122,7 @@ inpqstrg(const char *src, const char **e dst = strg + (slen - 1); slen *= 2; } - *dst++ = (char)c; + *dst++ = c; if ((c = *src++) == '\0') inperr("missing closing quote"); }
CVS commit: src/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Thu Aug 5 06:45:37 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: read.c Log Message: lint: fix handling of __int128_t/__uint128_t in lint2 Previously, lint exited with "bad type: J u". To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.46 src/usr.bin/xlint/lint2/read.c:1.47 --- src/usr.bin/xlint/lint2/read.c:1.46 Sat Jul 31 19:52:44 2021 +++ src/usr.bin/xlint/lint2/read.c Thu Aug 5 06:45:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.46 2021/07/31 19:52:44 rillig Exp $ */ +/* $NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.46 2021/07/31 19:52:44 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $"); #endif #include @@ -838,6 +838,15 @@ gettlen(const char *cp, const char **epp t = QUAD; } break; +#ifdef INT128_SIZE + case 'J': + if (s == 'u') { + t = UINT128; + } else if (s == '\0') { + t = INT128; + } + break; +#endif case 'D': if (s == 's') { t = FLOAT;
CVS commit: src/usr.bin/rlogin
Module Name:src Committed By: chs Date: Tue Aug 3 23:21:07 UTC 2021 Modified Files: src/usr.bin/rlogin: rlogin.c Log Message: revert rev 1.45: "PR/54435: Adjust for new kernel behavior of soreceive(9) clearing MSG_OOB" That change was trying to make rlogin work again after the SIOCATMARK ioctl was broken, but that kernel bug has now been fixed, so the original rlogin code now works again. Further, the changed rlogin code actually did the wrong thing, by treating reception of the MSG_OOB byte as meaning that we are now "at the mark", but that is not true... we are "at the mark" only when we have reached the point in the stream where the MSG_OOB byte was originally, as indicated by SIOCATMARK. So going back to the previous code seems best all around. ok'd by christos. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/rlogin/rlogin.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/rlogin/rlogin.c diff -u src/usr.bin/rlogin/rlogin.c:1.47 src/usr.bin/rlogin/rlogin.c:1.48 --- src/usr.bin/rlogin/rlogin.c:1.47 Sun May 3 16:32:16 2020 +++ src/usr.bin/rlogin/rlogin.c Tue Aug 3 23:21:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $ */ +/* $NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $ */ /* * Copyright (c) 1983, 1990, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "@(#)rlogin.c 8.4 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: rlogin.c,v 1.47 2020/05/03 16:32:16 christos Exp $"); +__RCSID("$NetBSD: rlogin.c,v 1.48 2021/08/03 23:21:07 chs Exp $"); #endif #endif /* not lint */ @@ -577,34 +577,16 @@ static pid_t ppid; static ssize_t rcvcnt, rcvstate; static char rcvbuf[8 * 1024]; -static int -recvx(int fd, void *buf, size_t len, int flags, int *msgflags) -{ - struct msghdr msg; - struct iovec iov; - int error; - - memset(, 0, sizeof(msg)); - msg.msg_iov = - iov.iov_base = buf; - iov.iov_len = len; - error = recvmsg(fd, , flags); - if (error) - return error; - *msgflags = msg.msg_flags; - return 0; -} - static void oob(int signo) { struct termios tty; - int atmark = 0; + int atmark; ssize_t n, rcvd; char waste[BUFSIZ], mark; rcvd = 0; - while (recvx(rem, , 1, MSG_OOB, ) == -1) { + while (recv(rem, , 1, MSG_OOB) == -1) { switch (errno) { case EWOULDBLOCK: /* @@ -628,7 +610,6 @@ oob(int signo) return; } } - atmark &= MSG_OOB; if (mark & TIOCPKT_WINDOW) { /* Let server know about window size changes */ (void)kill(ppid, SIGUSR1); @@ -645,8 +626,17 @@ oob(int signo) } if (mark & TIOCPKT_FLUSHWRITE) { (void)tcflush(1, TCIOFLUSH); - if (!atmark) + for (;;) { + if (ioctl(rem, SIOCATMARK, ) < 0) { +warn("ioctl SIOCATMARK (ignored)"); +break; + } + if (atmark) +break; n = read(rem, waste, sizeof (waste)); + if (n <= 0) +break; + } /* * Don't want any pending data to be output, so clear the recv * buffer. If we were hanging on a write when interrupted,
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Tue Aug 3 17:44:59 UTC 2021 Modified Files: src/usr.bin/xlint/common: emit.c externs.h tyname.c src/usr.bin/xlint/lint1: tree.c Log Message: lint: clean up and move 'sametype' This function is only used by lint1. That's good since the lint2 code was completely broken, as it would regard any two struct types as being the same. Remove the large switch statement since it is unlikely that there will be new type derivations in C anytime soon. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.43 -r1.44 src/usr.bin/xlint/common/tyname.c cvs rdiff -u -r1.326 -r1.327 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/emit.c diff -u src/usr.bin/xlint/common/emit.c:1.11 src/usr.bin/xlint/common/emit.c:1.12 --- src/usr.bin/xlint/common/emit.c:1.11 Sat Mar 27 11:08:00 2021 +++ src/usr.bin/xlint/common/emit.c Tue Aug 3 17:44:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.11 2021/03/27 11:08:00 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.12 2021/08/03 17:44:58 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,10 +37,9 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit.c,v 1.11 2021/03/27 11:08:00 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.12 2021/08/03 17:44:58 rillig Exp $"); #endif -#include #include #include Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.17 src/usr.bin/xlint/common/externs.h:1.18 --- src/usr.bin/xlint/common/externs.h:1.17 Sun Aug 1 18:13:53 2021 +++ src/usr.bin/xlint/common/externs.h Tue Aug 3 17:44:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.17 2021/08/01 18:13:53 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.18 2021/08/03 17:44:58 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -47,7 +47,6 @@ extern void inittyp(void); * tyname.c */ extern const char *type_name(const type_t *); -extern bool sametype(const type_t *, const type_t *); extern const char *tspec_name(tspec_t); /* Index: src/usr.bin/xlint/common/tyname.c diff -u src/usr.bin/xlint/common/tyname.c:1.43 src/usr.bin/xlint/common/tyname.c:1.44 --- src/usr.bin/xlint/common/tyname.c:1.43 Fri Jul 2 18:22:09 2021 +++ src/usr.bin/xlint/common/tyname.c Tue Aug 3 17:44:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.43 2021/07/02 18:22:09 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.44 2021/08/03 17:44:58 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.43 2021/07/02 18:22:09 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.44 2021/08/03 17:44:58 rillig Exp $"); #endif #include @@ -59,7 +59,7 @@ __RCSID("$NetBSD: tyname.c,v 1.43 2021/0 /* A tree of strings. */ typedef struct name_tree_node { - char *ntn_name; + const char *ntn_name; struct name_tree_node *ntn_less; struct name_tree_node *ntn_greater; } name_tree_node; @@ -85,7 +85,7 @@ new_name_tree_node(const char *name) return n; } -/* Return the canonical instance of the string, with unlimited life time. */ +/* Return the canonical instance of the string, with unlimited lifetime. */ static const char * intern(const char *name) { @@ -189,70 +189,6 @@ tspec_name(tspec_t t) } } -bool -sametype(const type_t *t1, const type_t *t2) -{ - tspec_t t; - - if (t1->t_tspec != t2->t_tspec) - return false; - - /* Ignore const/volatile */ - - switch (t = t1->t_tspec) { - case BOOL: - case CHAR: - case UCHAR: - case SCHAR: - case SHORT: - case USHORT: - case INT: - case UINT: - case LONG: - case ULONG: - case QUAD: - case UQUAD: -#ifdef INT128_SIZE - case INT128: - case UINT128: -#endif - case FLOAT: - case DOUBLE: - case LDOUBLE: - case VOID: - case FUNC: - case COMPLEX: - case FCOMPLEX: - case DCOMPLEX: - case LCOMPLEX: - return true; - case ARRAY: - if (t1->t_dim != t2->t_dim) - return false; - /*FALLTHROUGH*/ - case PTR: - return sametype(t1->t_subt, t2->t_subt); - case ENUM: -#ifdef t_enum - return strcmp(t1->t_enum->en_tag->s_name, - t2->t_enum->en_tag->s_name) == 0; -#else - return true; -#endif - case STRUCT: - case UNION: -#ifdef t_str - return strcmp(t1->t_str->sou_tag->s_name, - t2->t_str->sou_tag->s_name) == 0; -#else - return true; -#endif - default: - INTERNAL_ERROR("tyname(%d)", t); - return false; - } -} - static void type_name_of_function(buffer *buf, const type_t *tp) { Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.326 src/usr.bin/xlint/lint1/tree.c:1.327 --- src/usr.bin/xlint/lint1/tree.c:1.326 Sun Aug 1 19:11:54 2021 +++ src/usr.bin/xlint/lint1/tree.c Tue Aug 3 17:44:59 2021 @@ -1,4
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Tue Aug 3 17:27:48 UTC 2021 Modified Files: src/usr.bin/xlint/common: param.h Log Message: lint: reduce number of negations in preprocessor condition No functional change. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/common/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/param.h diff -u src/usr.bin/xlint/common/param.h:1.8 src/usr.bin/xlint/common/param.h:1.9 --- src/usr.bin/xlint/common/param.h:1.8 Wed Dec 30 11:43:13 2020 +++ src/usr.bin/xlint/common/param.h Tue Aug 3 17:27:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.8 2020/12/30 11:43:13 rillig Exp $ */ +/* $NetBSD: param.h,v 1.9 2021/08/03 17:27:48 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -63,7 +63,7 @@ /* * The sparc64 long double code generation is broken in old gcc. */ -#if !defined(__sparc64__) || !defined(__GNUC__) || __GNUC__ > 2 +#if !(defined(__sparc64__) && defined(__GNUC__) && __GNUC__ <= 2) typedef long double ldbl_t; #else typedef double ldbl_t;
CVS commit: src/usr.bin/xlint/common
Module Name:src Committed By: rillig Date: Tue Aug 3 17:20:02 UTC 2021 Modified Files: src/usr.bin/xlint/common: mem.c Log Message: lint: make memory management code easier to read No functional change. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/common/mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/mem.c diff -u src/usr.bin/xlint/common/mem.c:1.15 src/usr.bin/xlint/common/mem.c:1.16 --- src/usr.bin/xlint/common/mem.c:1.15 Sun Aug 1 18:13:53 2021 +++ src/usr.bin/xlint/common/mem.c Tue Aug 3 17:20:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $ */ +/* $NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $"); +__RCSID("$NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $"); #endif #include @@ -46,53 +46,41 @@ __RCSID("$NetBSD: mem.c,v 1.15 2021/08/0 #include "lint.h" -static void __attribute__((noreturn)) -nomem(void) +static void * +not_null(void *ptr) { - errx(1, "virtual memory exhausted"); + if (ptr == NULL) + errx(1, "virtual memory exhausted"); + return ptr; } void * xmalloc(size_t s) { - void *p; - if ((p = malloc(s)) == NULL) - nomem(); - return p; + return not_null(malloc(s)); } void * xcalloc(size_t n, size_t s) { - void *p; - if ((p = calloc(n, s)) == NULL) - nomem(); - return p; + return not_null(calloc(n, s)); } void * xrealloc(void *p, size_t s) { - void *n; - if ((n = realloc(p, s)) == NULL) { - free(p); - nomem(); - } - return n; + return not_null(realloc(p, s)); } char * xstrdup(const char *s) { - char *s2; - if ((s2 = strdup(s)) == NULL) - nomem(); - return s2; + return not_null(strdup(s)); } char * @@ -106,6 +94,6 @@ xasprintf(const char *fmt, ...) e = vasprintf(, fmt, ap); va_end(ap); if (e < 0) - nomem(); + not_null(NULL); return str; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: wiz Date: Tue Aug 3 07:12:50 UTC 2021 Modified Files: src/usr.bin/make: make.1 Log Message: Document :On modifiers in more detail. To generate a diff of this commit: cvs rdiff -u -r1.298 -r1.299 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.298 src/usr.bin/make/make.1:1.299 --- src/usr.bin/make/make.1:1.298 Fri Jul 30 22:16:09 2021 +++ src/usr.bin/make/make.1 Tue Aug 3 07:12:50 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.298 2021/07/30 22:16:09 rillig Exp $ +.\" $NetBSD: make.1,v 1.299 2021/08/03 07:12:50 wiz Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd July 30, 2021 +.Dd August 3, 2021 .Dt MAKE 1 .Os .Sh NAME @@ -1235,11 +1235,13 @@ Orders every word in variable alphabetic .It Cm \&:On Orders every word in variable numerically. A number followed by one of -.Ql K , +.Ql k , .Ql M or .Ql G -is multiplied by the appropriate factor. +is multiplied by the appropriate factor (1024 (k), 1048576 (M), or +1073741824 (G)). +Both upper- and lower-case letters are accepted. .It Cm \&:Or Orders every word in variable in reverse alphabetical order. .It Cm \&:Orn
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Tue Aug 3 04:46:49 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: varmod-order-numeric.mk varmod-order-reverse.mk varmod-order-shuffle.mk varmod-order-string.mk varmod-order.exp varmod-order.mk Log Message: tests/make: fix test for the variable modifier ':On' The variable modifier ':On' sorts words numerically. If these words are not numeric at all, they get assigned the numeric value 0. Internally, ':On' uses qsort for sorting the words. Since qsort is not specified to use a stable sorting algorithm, the test data must only use words that either are written in the same way or that are numerically different. The test varmod-order failed this requirement by trying to numerically sort a list of non-numeric words. This led to different results on BSD and Ubuntu, as could be expected. To fix the tests, distinguish between words and numbers in the tests. While here, clean up the tests for all variants of the variable modifier ':O'. Found by sjg on Ubuntu. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-order-numeric.mk \ src/usr.bin/make/unit-tests/varmod-order-reverse.mk \ src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-order-shuffle.mk \ src/usr.bin/make/unit-tests/varmod-order.mk cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-order-string.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/varmod-order-numeric.mk diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.4 src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.5 --- src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.4 Sat Jul 31 20:55:46 2021 +++ src/usr.bin/make/unit-tests/varmod-order-numeric.mk Tue Aug 3 04:46:49 2021 @@ -1,11 +1,17 @@ -# $NetBSD: varmod-order-numeric.mk,v 1.4 2021/07/31 20:55:46 rillig Exp $ +# $NetBSD: varmod-order-numeric.mk,v 1.5 2021/08/03 04:46:49 rillig Exp $ # -# Tests for the :On variable modifier, which returns the words, sorted in -# ascending numeric order. +# Tests for the variable modifiers ':On', which returns the words, sorted in +# ascending numeric order, and for ':Orn' and ':Onr', which additionally +# reverse the order. +# +# The variable modifiers ':On', ':Onr' and ':Orn' were added in var.c 1.939 +# from 2021-07-30. # This list contains only 32-bit numbers since the make code needs to conform # to C90, which does not provide integer types larger than 32 bit. It uses -# 'long long' by default, but that type is overridable if necessary. +# 'long long' by default, but that type is overridable if necessary to support +# older environments. +# # To get 53-bit integers even in C90, it would be possible to switch to # 'double' instead, but that would allow floating-point numbers as well, which # is out of scope for this variable modifier. @@ -24,6 +30,14 @@ NUMBERS= 3 5 7 1 42 -42 5K -3m 1M 1k -2G . error ${NUMBERS:Onr} .endif +# Duplicate numbers are preserved in the output. In this case the +# equal-valued numbers are spelled the same, so they are indistinguishable in +# the output. +DUPLICATES= 3 1 2 2 1 1 # https://oeis.org/A034002 +.if ${DUPLICATES:On} != "1 1 1 2 2 3" +. error ${DUPLICATES:On} +.endif + # If there are several numbers that have the same integer value, they are # returned in unspecified order. SAME_VALUE:= ${:U 79 80 0x0050 81 :On} @@ -32,9 +46,9 @@ SAME_VALUE:= ${:U 79 80 0x0050 81 :On} .endif # Hexadecimal and octal numbers are supported as well. -OCTAL= 0 010 0x7 9 -.if ${OCTAL:On} != "0 0x7 010 9" -. error ${OCTAL:On} +MIXED_BASE= 0 010 0x7 9 +.if ${MIXED_BASE:On} != "0 0x7 010 9" +. error ${MIXED_BASE:On} .endif all: Index: src/usr.bin/make/unit-tests/varmod-order-reverse.mk diff -u src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.4 src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.5 --- src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.4 Sat Oct 24 08:46:08 2020 +++ src/usr.bin/make/unit-tests/varmod-order-reverse.mk Tue Aug 3 04:46:49 2021 @@ -1,13 +1,12 @@ -# $NetBSD: varmod-order-reverse.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $ +# $NetBSD: varmod-order-reverse.mk,v 1.5 2021/08/03 04:46:49 rillig Exp $ # # Tests for the :Or variable modifier, which returns the words, sorted in # descending order. -NUMBERS= one two three four five six seven eight nine ten +WORDS= one two three four five six seven eight nine ten -.if ${NUMBERS:Or} != "two three ten six seven one nine four five eight" -. error ${NUMBERS:Or} +.if ${WORDS:Or} != "two three ten six seven one nine four five eight" +. error ${WORDS:Or} .endif all: - @:; Index: src/usr.bin/make/unit-tests/varmod-order.exp diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.4
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Aug 2 20:58:39 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: oper.c Log Message: lint: expand abbreviations in definitions of operator properties No functional change. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint1/oper.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/oper.c diff -u src/usr.bin/xlint/lint1/oper.c:1.9 src/usr.bin/xlint/lint1/oper.c:1.10 --- src/usr.bin/xlint/lint1/oper.c:1.9 Sat Mar 20 20:56:58 2021 +++ src/usr.bin/xlint/lint1/oper.c Mon Aug 2 20:58:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: oper.c,v 1.9 2021/03/20 20:56:58 rillig Exp $ */ +/* $NetBSD: oper.c,v 1.10 2021/08/02 20:58:39 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,17 +36,23 @@ const mod_t modtab[NOPS] = #define begin_ops() { #define op(name, repr, \ - bi, lo, tb, rb, \ - in, ic, ar, sc, \ - fo, va, ts, ba, \ - se, lu, ru, pc, \ - cm, ve, de, ew) \ + is_binary, is_logical, takes_bool, requires_bool, \ + is_integer, is_complex, is_arithmetic, is_scalar, \ + can_fold, is_value, is_test, balances_operands, \ + side_effects, left_unsigned, right_unsigned, \ + precedence_confusion, is_comparison, \ + valid_on_enum, bad_on_enum, warn_if_eq) \ { \ - bi + 0 > 0, lo + 0 > 0, tb + 0 > 0, rb + 0 > 0, \ - in + 0 > 0, ic + 0 > 0, ar + 0 > 0, sc + 0 > 0, \ - fo + 0 > 0, va + 0 > 0, ts + 0 > 0, ba + 0 > 0, \ - se + 0 > 0, lu + 0 > 0, ru + 0 > 0, pc + 0 > 0, \ - cm + 0 > 0, ve + 0 > 0, de + 0 > 0, ew + 0 > 0, \ + is_binary + 0 > 0, is_logical + 0 > 0, \ + takes_bool + 0 > 0, requires_bool + 0 > 0, \ + is_integer + 0 > 0, is_complex + 0 > 0, \ + is_arithmetic + 0 > 0, is_scalar + 0 > 0, \ + can_fold + 0 > 0, is_value + 0 > 0, \ + is_test + 0 > 0, balances_operands + 0 > 0, \ + side_effects + 0 > 0, left_unsigned + 0 > 0, \ + right_unsigned + 0 > 0, precedence_confusion + 0 > 0, \ + is_comparison + 0 > 0, valid_on_enum + 0 > 0, \ + bad_on_enum + 0 > 0, warn_if_eq + 0 > 0, \ repr, \ }, #define end_ops(n) };
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 19:18:10 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: clean up debug logging in the C grammar To generate a diff of this commit: cvs rdiff -u -r1.353 -r1.354 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.353 src/usr.bin/xlint/lint1/cgram.y:1.354 --- src/usr.bin/xlint/lint1/cgram.y:1.353 Sun Aug 1 06:40:37 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Aug 1 19:18:10 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.354 2021/08/01 19:18:10 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.354 2021/08/01 19:18:10 rillig Exp $"); #endif #include @@ -75,7 +75,7 @@ static sym_t *symbolrename(sym_t *, sbuf static void CLEAR_WARN_FLAGS(const char *file, size_t line) { - printf("%s:%zu: clearing flags\n", file, line); + debug_step("%s:%zu: clearing flags", file, line); clear_warn_flags(); olwarn = LWARN_BAD; } @@ -84,7 +84,7 @@ static void SAVE_WARN_FLAGS(const char *file, size_t line) { lint_assert(olwarn == LWARN_BAD); - printf("%s:%zu: saving flags %d\n", file, line, lwarn); + debug_step("%s:%zu: saving flags %d", file, line, lwarn); olwarn = lwarn; } @@ -93,18 +93,16 @@ RESTORE_WARN_FLAGS(const char *file, siz { if (olwarn != LWARN_BAD) { lwarn = olwarn; - printf("%s:%zu: restoring flags %d\n", file, line, lwarn); + debug_step("%s:%zu: restoring flags %d", file, line, lwarn); olwarn = LWARN_BAD; } else CLEAR_WARN_FLAGS(file, line); } -#define cgram_debug(fmt, args...) printf("cgram_debug: " fmt "\n", ##args) #else #define CLEAR_WARN_FLAGS(f, l) clear_warn_flags(), olwarn = LWARN_BAD #define SAVE_WARN_FLAGS(f, l) olwarn = lwarn #define RESTORE_WARN_FLAGS(f, l) \ (void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn)) -#define cgram_debug(fmt, args...) do { } while (false) #endif #define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__) @@ -383,11 +381,11 @@ identifier_sym: /* helper for struct/u /* K ???, C90 ???, C99 6.4.2.1, C11 ??? */ identifier: T_NAME { - cgram_debug("name '%s'", $1->sb_name); + debug_printf("cgram: name '%s'", $1->sb_name); $$ = $1; } | T_TYPENAME { - cgram_debug("typename '%s'", $1->sb_name); + debug_printf("cgram: typename '%s'", $1->sb_name); $$ = $1; } ;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 19:11:54 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: debug.c externs1.h main1.c tree.c Log Message: lint: merge duplicate debugging code The functions 'debug_node' and 'display_expression' were similar enough to be merged. Migrate debug_node to use the existing debug logging functions. Remove the now unused option 'd' from the options string. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.127 -r1.128 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.325 -r1.326 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.1 src/usr.bin/xlint/lint1/debug.c:1.2 --- src/usr.bin/xlint/lint1/debug.c:1.1 Sat Jul 31 18:16:42 2021 +++ src/usr.bin/xlint/lint1/debug.c Sun Aug 1 19:11:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.1 2021/07/31 18:16:42 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.2 2021/08/01 19:11:54 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,9 +35,11 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: debug.c,v 1.1 2021/07/31 18:16:42 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.2 2021/08/01 19:11:54 rillig Exp $"); #endif +#include + #include "lint1.h" @@ -104,40 +106,54 @@ void } void -debug_node(const tnode_t *tn, int indent) +debug_node(const tnode_t *tn) { op_t op; if (tn == NULL) { - printf("%*s" "null\n", indent, ""); + debug_step("null"); return; } op = tn->tn_op; - printf("%*s%s with type '%s'%s%s", - 2 * indent, "", + debug_indent(); + debug_printf("'%s' with type '%s'%s%s", op == CVT && !tn->tn_cast ? "convert" : modtab[op].m_name, type_name(tn->tn_type), tn->tn_lvalue ? ", lvalue" : "", tn->tn_parenthesized ? ", parenthesized" : ""); if (op == NAME) - printf(" %s\n", tn->tn_sym->s_name); + debug_printf(" %s %s\n", tn->tn_sym->s_name, + storage_class_name(tn->tn_sym->s_scl)); else if (op == CON && is_floating(tn->tn_type->t_tspec)) - printf(", value %Lg", tn->tn_val->v_ldbl); + debug_printf(", value %Lg", tn->tn_val->v_ldbl); else if (op == CON && is_uinteger(tn->tn_type->t_tspec)) - printf(", value %llu\n", (unsigned long long)tn->tn_val->v_quad); + debug_printf(", value %llu\n", (unsigned long long)tn->tn_val->v_quad); else if (op == CON && is_integer(tn->tn_type->t_tspec)) - printf(", value %lld\n", (long long)tn->tn_val->v_quad); + debug_printf(", value %lld\n", (long long)tn->tn_val->v_quad); else if (op == CON) - printf(", unknown value\n"); - else if (op == STRING) - printf(", length %zu\n", tn->tn_string->st_len); - else { - printf("\n"); + debug_printf(", unknown value\n"); + else if (op == STRING && tn->tn_string->st_tspec == CHAR) + debug_printf(", length %zu, \"%s\"\n", + tn->tn_string->st_len, tn->tn_string->st_cp); + else if (op == STRING && tn->tn_string->st_tspec == WCHAR) { + char *s; + size_t n; + n = MB_CUR_MAX * (tn->tn_string->st_len + 1); + s = xmalloc(n); + (void)wcstombs(s, tn->tn_string->st_wcp, n); + debug_printf(", length %zu, L\"%s\"", + tn->tn_string->st_len, s); + free(s); + + } else { + debug_printf("\n"); - debug_node(tn->tn_left, indent + 1); + debug_indent_inc(); + debug_node(tn->tn_left); if (modtab[op].m_binary || tn->tn_right != NULL) - debug_node(tn->tn_right, indent + 1); + debug_node(tn->tn_right); + debug_indent_dec(); } } Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.127 src/usr.bin/xlint/lint1/externs1.h:1.128 --- src/usr.bin/xlint/lint1/externs1.h:1.127 Sun Aug 1 18:37:29 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sun Aug 1 19:11:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.127 2021/08/01 18:37:29 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.128 2021/08/01 19:11:54 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -115,7 +115,7 @@ extern void expr_restore_memory(struct m */ #ifdef DEBUG -void debug_node(const tnode_t *, int); +void debug_node(const tnode_t *); void debug_printf(const char *fmt, ...) __printflike(1, 2); void debug_indent(void); void debug_indent_inc(void); @@ -127,7 +127,7 @@ void debug_leave(const char *); #define debug_leave() (debug_leave)(__func__) #else #define debug_noop() do { } while (false) -#define debug_node(tn, indent) debug_noop() +#define debug_node(tn) debug_noop() #define debug_printf(...) debug_noop() #define debug_indent() debug_noop() #define debug_step(...) debug_noop() Index: src/usr.bin/xlint/lint1/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.52 src/usr.bin/xlint/lint1/main1.c:1.53 --- src/usr.bin/xlint/lint1/main1.c:1.52 Sun Aug 1 18:37:29 2021 +++
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 18:37:29 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c externs1.h main1.c tree.c Log Message: lint: remove option -d, clean up debug logging The command line option -d was not used by /usr/bin/lint, and it only triggered a handful of debug messages. Move this debug logging over to the compile-time -DDEBUG setting. Move display_expression further up to avoid the forward declaration. To generate a diff of this commit: cvs rdiff -u -r1.216 -r1.217 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.126 -r1.127 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.51 -r1.52 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.324 -r1.325 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.216 src/usr.bin/xlint/lint1/decl.c:1.217 --- src/usr.bin/xlint/lint1/decl.c:1.216 Sun Aug 1 06:40:37 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Aug 1 18:37:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.217 2021/08/01 18:37:29 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.217 2021/08/01 18:37:29 rillig Exp $"); #endif #include @@ -649,8 +649,7 @@ begin_declaration_level(scl_t sc) dcs = di; di->d_ctx = sc; di->d_ldlsym = >d_dlsyms; - if (dflag) - (void)printf("%s(%p %s)\n", __func__, dcs, scl_name(sc)); + debug_step("%s(%p %s)", __func__, dcs, scl_name(sc)); } /* @@ -661,9 +660,7 @@ end_declaration_level(void) { dinfo_t *di; - if (dflag) - (void)printf("%s(%p %s)\n", - __func__, dcs, scl_name(dcs->d_ctx)); + debug_step("%s(%p %s)", __func__, dcs, scl_name(dcs->d_ctx)); lint_assert(dcs->d_next != NULL); di = dcs; Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.126 src/usr.bin/xlint/lint1/externs1.h:1.127 --- src/usr.bin/xlint/lint1/externs1.h:1.126 Sat Jul 31 19:12:35 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sun Aug 1 18:37:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.126 2021/07/31 19:12:35 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.127 2021/08/01 18:37:29 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,6 @@ extern int aflag; extern bool bflag; extern bool cflag; extern bool c11flag; -extern bool dflag; extern bool eflag; extern bool Fflag; extern bool gflag; Index: src/usr.bin/xlint/lint1/main1.c diff -u src/usr.bin/xlint/lint1/main1.c:1.51 src/usr.bin/xlint/lint1/main1.c:1.52 --- src/usr.bin/xlint/lint1/main1.c:1.51 Sun Aug 1 06:40:37 2021 +++ src/usr.bin/xlint/lint1/main1.c Sun Aug 1 18:37:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.51 2021/08/01 06:40:37 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.52 2021/08/01 18:37:29 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.51 2021/08/01 06:40:37 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.52 2021/08/01 18:37:29 rillig Exp $"); #endif #include @@ -71,9 +71,6 @@ bool cflag; /* Allow features from C11, C99 and C90. */ bool c11flag; -/* Print various debug information. */ -bool dflag; - /* Perform stricter checking of enum types and operations on enum types. */ bool eflag; @@ -186,7 +183,6 @@ main(int argc, char *argv[]) case 'a': aflag++; break; case 'b': bflag = true; break; case 'c': cflag = true; break; - case 'd': dflag = true; break; case 'e': eflag = true; break; case 'F': Fflag = true; break; case 'g': gflag = true; break; @@ -257,8 +253,6 @@ main(int argc, char *argv[]) #ifdef DEBUG setvbuf(stdout, NULL, _IONBF, 0); #endif - if (dflag) - setvbuf(stdout, NULL, _IONBF, 0); #ifdef YYDEBUG if (yflag) yydebug = 1; Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.324 src/usr.bin/xlint/lint1/tree.c:1.325 --- src/usr.bin/xlint/lint1/tree.c:1.324 Sun Aug 1 14:45:39 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Aug 1 18:37:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.325 2021/08/01 18:37:29 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.325 2021/08/01 18:37:29 rillig Exp $"); #endif #include @@ -90,7 +90,6 @@ static tnode_t *fold_float(tnode_t *); static tnode_t *check_function_arguments(type_t *, tnode_t *); static tnode_t *check_prototype_argument(int, type_t *,
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sun Aug 1 18:13:54 UTC 2021 Modified Files: src/usr.bin/xlint/common: externs.h mem.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: make xasprintf simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/mem.c cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/xlint/xlint.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.16 src/usr.bin/xlint/common/externs.h:1.17 --- src/usr.bin/xlint/common/externs.h:1.16 Sun Aug 1 18:07:35 2021 +++ src/usr.bin/xlint/common/externs.h Sun Aug 1 18:13:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.16 2021/08/01 18:07:35 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.17 2021/08/01 18:13:53 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -57,7 +57,7 @@ extern void *xmalloc(size_t); extern void *xcalloc(size_t, size_t); extern void *xrealloc(void *, size_t); extern char *xstrdup(const char *); -extern void xasprintf(char **, const char *, ...) __printflike(2, 3); +extern char *xasprintf(const char *, ...) __printflike(1, 2); /* * emit.c Index: src/usr.bin/xlint/common/mem.c diff -u src/usr.bin/xlint/common/mem.c:1.14 src/usr.bin/xlint/common/mem.c:1.15 --- src/usr.bin/xlint/common/mem.c:1.14 Sun Aug 1 18:07:35 2021 +++ src/usr.bin/xlint/common/mem.c Sun Aug 1 18:13:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $ */ +/* $NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $"); +__RCSID("$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $"); #endif #include @@ -82,8 +82,7 @@ xrealloc(void *p, size_t s) free(p); nomem(); } - p = n; - return p; + return n; } char * @@ -96,15 +95,17 @@ xstrdup(const char *s) return s2; } -void -xasprintf(char **buf, const char *fmt, ...) +char * +xasprintf(const char *fmt, ...) { + char *str; int e; va_list ap; va_start(ap, fmt); - e = vasprintf(buf, fmt, ap); + e = vasprintf(, fmt, ap); va_end(ap); if (e < 0) nomem(); + return str; } Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.63 src/usr.bin/xlint/xlint/xlint.c:1.64 --- src/usr.bin/xlint/xlint/xlint.c:1.63 Sun May 2 21:05:42 2021 +++ src/usr.bin/xlint/xlint/xlint.c Sun Aug 1 18:13:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.63 2021/05/02 21:05:42 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.63 2021/05/02 21:05:42 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $"); #endif #include @@ -696,9 +696,9 @@ fname(const char *name) return; } len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn); - xasprintf(, "%.*s.ln", (int)len, bn); + ofn = xasprintf("%.*s.ln", (int)len, bn); } else { - xasprintf(, "%slint1.XX", tmpdir); + ofn = xasprintf("%slint1.XX", tmpdir); fd = mkstemp(ofn); if (fd == -1) { warn("can't make temp");
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sun Aug 1 18:07:35 UTC 2021 Modified Files: src/usr.bin/xlint/common: externs.h mem.c src/usr.bin/xlint/lint1: mem1.c Log Message: lint: unexport nomem No functional change. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/common/mem.c cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/lint1/mem1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.15 src/usr.bin/xlint/common/externs.h:1.16 --- src/usr.bin/xlint/common/externs.h:1.15 Sun Aug 1 17:59:47 2021 +++ src/usr.bin/xlint/common/externs.h Sun Aug 1 18:07:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.15 2021/08/01 17:59:47 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.16 2021/08/01 18:07:35 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -57,7 +57,6 @@ extern void *xmalloc(size_t); extern void *xcalloc(size_t, size_t); extern void *xrealloc(void *, size_t); extern char *xstrdup(const char *); -extern void nomem(void); extern void xasprintf(char **, const char *, ...) __printflike(2, 3); /* Index: src/usr.bin/xlint/common/mem.c diff -u src/usr.bin/xlint/common/mem.c:1.13 src/usr.bin/xlint/common/mem.c:1.14 --- src/usr.bin/xlint/common/mem.c:1.13 Sun Aug 1 17:59:47 2021 +++ src/usr.bin/xlint/common/mem.c Sun Aug 1 18:07:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $ */ +/* $NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,18 +37,22 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $"); +__RCSID("$NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $"); #endif -#include -#include -#include #include #include #include #include "lint.h" +static void __attribute__((noreturn)) +nomem(void) +{ + + errx(1, "virtual memory exhausted"); +} + void * xmalloc(size_t s) { @@ -92,13 +96,6 @@ xstrdup(const char *s) return s2; } -void __attribute__((noreturn)) -nomem(void) -{ - - errx(1, "virtual memory exhausted"); -} - void xasprintf(char **buf, const char *fmt, ...) { Index: src/usr.bin/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.46 src/usr.bin/xlint/lint1/mem1.c:1.47 --- src/usr.bin/xlint/lint1/mem1.c:1.46 Sun Aug 1 17:59:47 2021 +++ src/usr.bin/xlint/lint1/mem1.c Sun Aug 1 18:07:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $"); #endif #include @@ -398,8 +398,8 @@ expr_save_memory(void) } /* - * Free all memory used for the current expression and the memory used - * be a previous expression and saved by expr_save_memory(). The next call to + * Free all memory used for the current expression and restore the memory used + * by a previous expression and saved by expr_save_memory(). The next call to * expr_free_all() frees the restored memory. */ void
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sun Aug 1 17:59:47 UTC 2021 Modified Files: src/usr.bin/xlint/common: externs.h mem.c src/usr.bin/xlint/lint1: mem1.c src/usr.bin/xlint/lint2: mem2.c Log Message: lint: remove xmapalloc Just trust the standard malloc to be smart enough. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/common/mem.c cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint2/mem2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/common/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.14 src/usr.bin/xlint/common/externs.h:1.15 --- src/usr.bin/xlint/common/externs.h:1.14 Sat Jan 16 02:40:02 2021 +++ src/usr.bin/xlint/common/externs.h Sun Aug 1 17:59:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.14 2021/01/16 02:40:02 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.15 2021/08/01 17:59:47 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -58,7 +58,6 @@ extern void *xcalloc(size_t, size_t); extern void *xrealloc(void *, size_t); extern char *xstrdup(const char *); extern void nomem(void); -extern void *xmapalloc(size_t); extern void xasprintf(char **, const char *, ...) __printflike(2, 3); /* Index: src/usr.bin/xlint/common/mem.c diff -u src/usr.bin/xlint/common/mem.c:1.12 src/usr.bin/xlint/common/mem.c:1.13 --- src/usr.bin/xlint/common/mem.c:1.12 Sun Apr 18 22:51:24 2021 +++ src/usr.bin/xlint/common/mem.c Sun Aug 1 17:59:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.12 2021/04/18 22:51:24 rillig Exp $ */ +/* $NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem.c,v 1.12 2021/04/18 22:51:24 rillig Exp $"); +__RCSID("$NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $"); #endif #include @@ -111,29 +111,3 @@ xasprintf(char **buf, const char *fmt, . if (e < 0) nomem(); } - -#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON) -#define MAP_ANON MAP_ANONYMOUS -#endif - -void * -xmapalloc(size_t len) -{ - static const int prot = PROT_READ | PROT_WRITE; - static int fd = -1; - void *p; -#ifdef MAP_ANON - static const int flags = MAP_ANON | MAP_PRIVATE; -#else - static const int flags = MAP_PRIVATE; - - if (fd == -1) { - if ((fd = open("/dev/zero", O_RDWR)) == -1) - err(1, "Cannot open `/dev/zero'"); - } -#endif - p = mmap(NULL, len, prot, flags, fd, (off_t)0); - if (p == (void *)-1) - err(1, "Cannot map memory for %lu bytes", (unsigned long)len); - return p; -} Index: src/usr.bin/xlint/lint1/mem1.c diff -u src/usr.bin/xlint/lint1/mem1.c:1.45 src/usr.bin/xlint/lint1/mem1.c:1.46 --- src/usr.bin/xlint/lint1/mem1.c:1.45 Sun Jul 4 09:13:59 2021 +++ src/usr.bin/xlint/lint1/mem1.c Sun Aug 1 17:59:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.45 2021/07/04 09:13:59 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem1.c,v 1.45 2021/07/04 09:13:59 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $"); #endif #include @@ -214,8 +214,7 @@ xnewblk(void) { memory_block *mb = xmalloc(sizeof(*mb)); - /* use mmap instead of malloc to avoid malloc's size overhead */ - mb->start = xmapalloc(mblklen); + mb->start = xmalloc(mblklen); mb->size = mblklen; return mb; Index: src/usr.bin/xlint/lint2/mem2.c diff -u src/usr.bin/xlint/lint2/mem2.c:1.11 src/usr.bin/xlint/lint2/mem2.c:1.12 --- src/usr.bin/xlint/lint2/mem2.c:1.11 Tue Dec 29 11:35:11 2020 +++ src/usr.bin/xlint/lint2/mem2.c Sun Aug 1 17:59:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mem2.c,v 1.11 2020/12/29 11:35:11 rillig Exp $ */ +/* $NetBSD: mem2.c,v 1.12 2021/08/01 17:59:47 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem2.c,v 1.11 2020/12/29 11:35:11 rillig Exp $"); +__RCSID("$NetBSD: mem2.c,v 1.12 2021/08/01 17:59:47 rillig Exp $"); #endif #include @@ -80,8 +80,7 @@ xalloc(size_t sz) /* Align to at least 8 bytes. */ sz = (sz + 7) & ~7L; if (nxtfree + sz > mblklen) { - /* use mmap() instead of malloc() to avoid malloc overhead. */ - mbuf = xmapalloc(mblklen); + mbuf = xmalloc(mblklen); (void)memset(mbuf, 0, mblklen); nxtfree = 0; }
CVS commit: src/usr.bin/crunch/crunchgen
Module Name:src Committed By: andvar Date: Sun Aug 1 15:52:11 UTC 2021 Modified Files: src/usr.bin/crunch/crunchgen: crunchgen.1 Log Message: fix syntax error and typo in overwritten. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.bin/crunch/crunchgen/crunchgen.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/crunch/crunchgen/crunchgen.1 diff -u src/usr.bin/crunch/crunchgen/crunchgen.1:1.41 src/usr.bin/crunch/crunchgen/crunchgen.1:1.42 --- src/usr.bin/crunch/crunchgen/crunchgen.1:1.41 Thu Jan 2 23:21:14 2020 +++ src/usr.bin/crunch/crunchgen/crunchgen.1 Sun Aug 1 15:52:11 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: crunchgen.1,v 1.41 2020/01/02 23:21:14 wiz Exp $ +.\" $NetBSD: crunchgen.1,v 1.42 2021/08/01 15:52:11 andvar Exp $ .\" .\" Copyright (c) 1994 University of Maryland .\" All Rights Reserved. @@ -128,9 +128,9 @@ Status messages are suppressed. .It Fl v Ar varspec Append a variable specification to the on-the fly generated Makefiles for the individual programs. -.It Fl V ar varspec +.It Fl V Ar varspec Set the variable in the top level Makefile, and pass it in the command -line of all sub-makes, so that it cannot be overwriten. +line of all sub-makes, so that it cannot be overwritten. .El .Sh CRUNCHGEN CONFIGURATION FILE COMMANDS .Nm
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 14:45:40 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: remove unreachable code from usual arithmetic conversions To generate a diff of this commit: cvs rdiff -u -r1.323 -r1.324 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.323 src/usr.bin/xlint/lint1/tree.c:1.324 --- src/usr.bin/xlint/lint1/tree.c:1.323 Sun Aug 1 13:49:17 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Aug 1 14:45:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.323 2021/08/01 13:49:17 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.323 2021/08/01 13:49:17 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $"); #endif #include @@ -1782,8 +1782,6 @@ balance(op_t op, tnode_t **lnp, tnode_t t = LCOMPLEX; } else if (lt == DCOMPLEX || rt == DCOMPLEX) { t = DCOMPLEX; - } else if (lt == COMPLEX || rt == COMPLEX) { - t = COMPLEX; } else if (lt == FCOMPLEX || rt == FCOMPLEX) { t = FCOMPLEX; } else if (lt == LDOUBLE || rt == LDOUBLE) {
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 08:03:43 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: lex.c lint1.h Log Message: lint: remove hash value from symbol buffer Conceptually, a symbol buffer does not need to remember its hash value since that belongs to the symbol table. This makes the code for the symbol table simpler. The number of hash calculations increases by about 5%, which is negligible. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.120 -r1.121 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.61 src/usr.bin/xlint/lint1/lex.c:1.62 --- src/usr.bin/xlint/lint1/lex.c:1.61 Sun Aug 1 07:46:51 2021 +++ src/usr.bin/xlint/lint1/lex.c Sun Aug 1 08:03:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.61 2021/08/01 07:46:51 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.62 2021/08/01 08:03:43 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.61 2021/08/01 07:46:51 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.62 2021/08/01 08:03:43 rillig Exp $"); #endif #include @@ -259,9 +259,11 @@ symt_t symtyp; static void -symtab_add_hash(sym_t *sym, size_t h) +symtab_add(sym_t *sym) { + size_t h; + h = hash(sym->s_name); if ((sym->s_link = symtab[h]) != NULL) symtab[h]->s_rlink = >s_link; sym->s_rlink = [h]; @@ -269,15 +271,6 @@ symtab_add_hash(sym_t *sym, size_t h) } static void -symtab_add(sym_t *sym) -{ - size_t h; - - h = hash(sym->s_name); - symtab_add_hash(sym, h); -} - -static void symtab_remove(sym_t *sym) { @@ -445,7 +438,6 @@ lex_name(const char *yytext, size_t yyle sb = allocsb(); sb->sb_name = yytext; sb->sb_len = yyleng; - sb->sb_hash = hash(yytext); if ((sym = search(sb)) != NULL && sym->s_keyword != NULL) { freesb(sb); return keyw(sym); @@ -473,10 +465,12 @@ lex_name(const char *yytext, size_t yyle static sym_t * search(sbuf_t *sb) { + int h; sym_t *sym; const struct kwtab *kw; - for (sym = symtab[sb->sb_hash]; sym != NULL; sym = sym->s_link) { + h = hash(sb->sb_name); + for (sym = symtab[h]; sym != NULL; sym = sym->s_link) { if (strcmp(sym->s_name, sb->sb_name) != 0) continue; kw = sym->s_keyword; @@ -1471,7 +1465,7 @@ getsym(sbuf_t *sb) symtyp = FVFT; - symtab_add_hash(sym, sb->sb_hash); + symtab_add(sym); *di->d_ldlsym = sym; di->d_ldlsym = >s_dlnxt; Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.120 src/usr.bin/xlint/lint1/lint1.h:1.121 --- src/usr.bin/xlint/lint1/lint1.h:1.120 Sat Jul 31 19:52:44 2021 +++ src/usr.bin/xlint/lint1/lint1.h Sun Aug 1 08:03:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.120 2021/07/31 19:52:44 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.121 2021/08/01 08:03:43 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -293,7 +293,6 @@ typedef struct sym { typedef struct sbuf { const char *sb_name; /* name of symbol */ size_t sb_len; /* length (without '\0') */ - int sb_hash; /* hash value */ sym_t *sb_sym; /* symbol table entry */ struct sbuf *sb_next; /* for freelist */ } sbuf_t;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 07:46:51 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: lex.c Log Message: lint: merge duplicate code for removing a symbol from the table No functional change. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.60 src/usr.bin/xlint/lint1/lex.c:1.61 --- src/usr.bin/xlint/lint1/lex.c:1.60 Sun Aug 1 06:58:58 2021 +++ src/usr.bin/xlint/lint1/lex.c Sun Aug 1 07:46:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.60 2021/08/01 06:58:58 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.61 2021/08/01 07:46:51 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.60 2021/08/01 06:58:58 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.61 2021/08/01 07:46:51 rillig Exp $"); #endif #include @@ -278,6 +278,16 @@ symtab_add(sym_t *sym) } static void +symtab_remove(sym_t *sym) +{ + + if ((*sym->s_rlink = sym->s_link) != NULL) + sym->s_link->s_rlink = sym->s_rlink; + sym->s_link = NULL; +} + + +static void add_keyword(const struct kwtab *kw, u_int deco) { sym_t *sym; @@ -1504,21 +1514,17 @@ mktempsym(type_t *t) return sym; } -/* - * Remove a symbol forever from the symbol table. s_block_level - * is set to -1 to avoid that the symbol will later be put - * back to the symbol table. - */ +/* Remove a symbol forever from the symbol table. */ void rmsym(sym_t *sym) { debug_step("rmsym '%s' %d '%s'", sym->s_name, (int)sym->s_kind, type_name(sym->s_type)); - if ((*sym->s_rlink = sym->s_link) != NULL) - sym->s_link->s_rlink = sym->s_rlink; + symtab_remove(sym); + + /* avoid that the symbol will later be put back to the symbol table */ sym->s_block_level = -1; - sym->s_link = NULL; } /* @@ -1535,9 +1541,7 @@ rmsyms(sym_t *syms) debug_step("rmsyms '%s' %d '%s'", sym->s_name, (int)sym->s_kind, type_name(sym->s_type)); - if ((*sym->s_rlink = sym->s_link) != NULL) -sym->s_link->s_rlink = sym->s_rlink; - sym->s_link = NULL; + symtab_remove(sym); sym->s_rlink = NULL; } } @@ -1574,10 +1578,8 @@ cleanup(void) for (i = 0; i < HSHSIZ1; i++) { for (sym = symtab[i]; sym != NULL; sym = nsym) { nsym = sym->s_link; - if (sym->s_block_level >= 1) { -if ((*sym->s_rlink = nsym) != NULL) - nsym->s_rlink = sym->s_rlink; - } + if (sym->s_block_level >= 1) +symtab_remove(sym); } }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 06:58:58 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: lex.c Log Message: lint: extract duplicate code for modifying the symbol table No functional change. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.59 src/usr.bin/xlint/lint1/lex.c:1.60 --- src/usr.bin/xlint/lint1/lex.c:1.59 Sun Aug 1 06:40:37 2021 +++ src/usr.bin/xlint/lint1/lex.c Sun Aug 1 06:58:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.59 2021/08/01 06:40:37 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.60 2021/08/01 06:58:58 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.59 2021/08/01 06:40:37 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.60 2021/08/01 06:58:58 rillig Exp $"); #endif #include @@ -259,10 +259,28 @@ symt_t symtyp; static void +symtab_add_hash(sym_t *sym, size_t h) +{ + + if ((sym->s_link = symtab[h]) != NULL) + symtab[h]->s_rlink = >s_link; + sym->s_rlink = [h]; + symtab[h] = sym; +} + +static void +symtab_add(sym_t *sym) +{ + size_t h; + + h = hash(sym->s_name); + symtab_add_hash(sym, h); +} + +static void add_keyword(const struct kwtab *kw, u_int deco) { sym_t *sym; - size_t h; char buf[256]; const char *name; @@ -298,11 +316,8 @@ add_keyword(const struct kwtab *kw, u_in } else if (kw->kw_token == T_QUAL) { sym->s_tqual = kw->kw_tqual; } - h = hash(sym->s_name); - if ((sym->s_link = symtab[h]) != NULL) - symtab[h]->s_rlink = >s_link; - sym->s_rlink = [h]; - symtab[h] = sym; + + symtab_add(sym); } /* @@ -1380,15 +1395,15 @@ lex_wide_string(void) } /* - * As noted above the scanner does not create new symbol table entries + * As noted above, the scanner does not create new symbol table entries * for symbols it cannot find in the symbol table. This is to avoid * putting undeclared symbols into the symbol table if a syntax error * occurs. * - * getsym() is called as soon as it is probably ok to put the symbol to the + * getsym() is called as soon as it is probably ok to put the symbol in the * symbol table. It is still possible that symbols are put in the symbol * table that are not completely declared due to syntax errors. To avoid too - * many problems in this case, symbols get type int in getsym(). + * many problems in this case, symbols get type 'int' in getsym(). * * XXX calls to getsym() should be delayed until decl1*() is called. */ @@ -1446,10 +1461,7 @@ getsym(sbuf_t *sb) symtyp = FVFT; - if ((sym->s_link = symtab[sb->sb_hash]) != NULL) - symtab[sb->sb_hash]->s_rlink = >s_link; - sym->s_rlink = [sb->sb_hash]; - symtab[sb->sb_hash] = sym; + symtab_add_hash(sym, sb->sb_hash); *di->d_ldlsym = sym; di->d_ldlsym = >s_dlnxt; @@ -1466,13 +1478,11 @@ sym_t * mktempsym(type_t *t) { static int n = 0; - int h; char *s = getlblk(block_level, 64); sym_t *sym = getblk(sizeof(*sym)); scl_t scl; (void)snprintf(s, 64, "%.8d_tmp", n++); - h = hash(s); scl = dcs->d_scl; if (scl == NOSCL) @@ -1486,10 +1496,7 @@ mktempsym(type_t *t) sym->s_used = true; sym->s_set = true; - if ((sym->s_link = symtab[h]) != NULL) - symtab[h]->s_rlink = >s_link; - sym->s_rlink = [h]; - symtab[h] = sym; + symtab_add(sym); *dcs->d_ldlsym = sym; dcs->d_ldlsym = >s_dlnxt; @@ -1542,15 +1549,10 @@ rmsyms(sym_t *syms) void inssym(int bl, sym_t *sym) { - int h; debug_step("inssym '%s' %d '%s'", sym->s_name, sym->s_kind, type_name(sym->s_type)); - h = hash(sym->s_name); - if ((sym->s_link = symtab[h]) != NULL) - symtab[h]->s_rlink = >s_link; - sym->s_rlink = [h]; - symtab[h] = sym; + symtab_add(sym); sym->s_block_level = bl; lint_assert(sym->s_link == NULL || sym->s_block_level >= sym->s_link->s_block_level); @@ -1589,12 +1591,10 @@ cleanup(void) sym_t * pushdown(const sym_t *sym) { - int h; sym_t *nsym; debug_step("pushdown '%s' %d '%s'", sym->s_name, (int)sym->s_kind, type_name(sym->s_type)); - h = hash(sym->s_name); nsym = getblk(sizeof(*nsym)); lint_assert(sym->s_block_level <= block_level); nsym->s_name = sym->s_name; @@ -1602,10 +1602,7 @@ pushdown(const sym_t *sym) nsym->s_kind = sym->s_kind; nsym->s_block_level = block_level; - if ((nsym->s_link = symtab[h]) != NULL) - symtab[h]->s_rlink = >s_link; - nsym->s_rlink = [h]; - symtab[h] = nsym; + symtab_add(nsym); *dcs->d_ldlsym = nsym; dcs->d_ldlsym = >s_dlnxt;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Aug 1 06:40:37 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c func.c lex.c main1.c Log Message: lint: add debug logging for symbol table, clean up debug logging When I tried to fix msg_115, I quickly ran into a segmentation fault, probably related to the symbol table. To better understand this part, log insertions and deletions. The other debug log messages do not need to mention the current file position anymore, this is what lex_next_line takes care of since scan.l 1.113 from 2021-01-05. To generate a diff of this commit: cvs rdiff -u -r1.352 -r1.353 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.215 -r1.216 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.58 -r1.59 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.50 -r1.51 src/usr.bin/xlint/lint1/main1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.352 src/usr.bin/xlint/lint1/cgram.y:1.353 --- src/usr.bin/xlint/lint1/cgram.y:1.352 Sat Jul 31 17:09:21 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Aug 1 06:40:37 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.352 2021/07/31 17:09:21 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.352 2021/07/31 17:09:21 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $"); #endif #include @@ -75,8 +75,7 @@ static sym_t *symbolrename(sym_t *, sbuf static void CLEAR_WARN_FLAGS(const char *file, size_t line) { - printf("%s:%d: %s:%zu: clearing flags\n", - curr_pos.p_file, curr_pos.p_line, file, line); + printf("%s:%zu: clearing flags\n", file, line); clear_warn_flags(); olwarn = LWARN_BAD; } @@ -85,8 +84,7 @@ static void SAVE_WARN_FLAGS(const char *file, size_t line) { lint_assert(olwarn == LWARN_BAD); - printf("%s:%d: %s:%zu: saving flags %d\n", - curr_pos.p_file, curr_pos.p_line, file, line, lwarn); + printf("%s:%zu: saving flags %d\n", file, line, lwarn); olwarn = lwarn; } @@ -95,8 +93,7 @@ RESTORE_WARN_FLAGS(const char *file, siz { if (olwarn != LWARN_BAD) { lwarn = olwarn; - printf("%s:%d: %s:%zu: restoring flags %d\n", - curr_pos.p_file, curr_pos.p_line, file, line, lwarn); + printf("%s:%zu: restoring flags %d\n", file, line, lwarn); olwarn = LWARN_BAD; } else CLEAR_WARN_FLAGS(file, line); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.215 src/usr.bin/xlint/lint1/decl.c:1.216 --- src/usr.bin/xlint/lint1/decl.c:1.215 Sat Jul 31 19:52:44 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Aug 1 06:40:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.215 2021/07/31 19:52:44 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.215 2021/07/31 19:52:44 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 rillig Exp $"); #endif #include @@ -3015,13 +3015,11 @@ check_usage(dinfo_t *di) mklwarn = lwarn; lwarn = LWARN_ALL; - debug_step("%s, %d: >temp lwarn = %d", - curr_pos.p_file, curr_pos.p_line, lwarn); + debug_step("begin lwarn %d", lwarn); for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) check_usage_sym(di->d_asm, sym); lwarn = mklwarn; - debug_step("%s, %d: #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.117 2021/07/31 19:07:52 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.118 2021/08/01 06:40:37 rillig Exp $"); #endif #include @@ -192,8 +192,7 @@ end_control_statement(control_statement_ static void set_reached(bool new_reached) { - debug_step("%s:%d: %s -> %s", - curr_pos.p_file, curr_pos.p_line, + debug_step("%s -> %s", reached ? "reachable" : "unreachable", new_reached ? "reachable" : "unreachable"); reached = new_reached; @@ -1327,8 +1326,7 @@ void linted(int n) { - debug_step("%s, %d: lwarn = %d", - curr_pos.p_file, curr_pos.p_line, n); + debug_step("set lwarn %d", n); lwarn = n; } Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.58 src/usr.bin/xlint/lint1/lex.c:1.59 --- src/usr.bin/xlint/lint1/lex.c:1.58 Sat Jul 31 19:07:52 2021 +++ src/usr.bin/xlint/lint1/lex.c Sun Aug 1 06:40:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.58 2021/07/31 19:07:52 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.59 2021/08/01 06:40:37 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 19:20:59 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: initialize shared types in the same order as in tspec_t This makes it easier to see whether there are any types missing, such as __uint128_t. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 src/usr.bin/xlint/lint1/decl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.213 src/usr.bin/xlint/lint1/decl.c:1.214 --- src/usr.bin/xlint/lint1/decl.c:1.213 Sat Jul 31 19:07:52 2021 +++ src/usr.bin/xlint/lint1/decl.c Sat Jul 31 19:20:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.214 2021/07/31 19:20:59 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.214 2021/07/31 19:20:59 rillig Exp $"); #endif #include @@ -105,6 +105,14 @@ initdecl(void) typetab = xcalloc(NTSPEC, sizeof(*typetab)); for (i = 0; i < NTSPEC; i++) typetab[i].t_tspec = NOTSPEC; + + /* + * The following two are not real types. They are only used by the + * parser to handle the keywords "signed" and "unsigned". + */ + typetab[SIGNED].t_tspec = SIGNED; + typetab[UNSIGN].t_tspec = UNSIGN; + typetab[BOOL].t_tspec = BOOL; typetab[CHAR].t_tspec = CHAR; typetab[SCHAR].t_tspec = SCHAR; @@ -117,20 +125,19 @@ initdecl(void) typetab[ULONG].t_tspec = ULONG; typetab[QUAD].t_tspec = QUAD; typetab[UQUAD].t_tspec = UQUAD; +#ifdef INT128_SIZE + /* TODO: add __int128_t */ + /* TODO: add __uint128_t */ +#endif typetab[FLOAT].t_tspec = FLOAT; typetab[DOUBLE].t_tspec = DOUBLE; typetab[LDOUBLE].t_tspec = LDOUBLE; + typetab[VOID].t_tspec = VOID; + /* struct, union, enum, ptr, array and func are not shared. */ + typetab[COMPLEX].t_tspec = COMPLEX; typetab[FCOMPLEX].t_tspec = FCOMPLEX; typetab[DCOMPLEX].t_tspec = DCOMPLEX; typetab[LCOMPLEX].t_tspec = LCOMPLEX; - typetab[COMPLEX].t_tspec = COMPLEX; - typetab[VOID].t_tspec = VOID; - /* - * Next two are not real types. They are only used by the parser - * to return keywords "signed" and "unsigned" - */ - typetab[SIGNED].t_tspec = SIGNED; - typetab[UNSIGN].t_tspec = UNSIGN; } /* Return the name of the "storage class" in the wider sense. */
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 19:12:35 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: externs1.h Log Message: lint: do not evaluate arguments of debug_step To analyze the unexpected test failure of op_shl_lp64, I had reverted debug_step to evaluate its arguments. I then accidentally committed that without running the tests again. Anyway, the previous commit can now be used as a demonstration that initdecl is indeed missing the initialization for __uint128_t, which leads to the internal error in op_shl_lp64. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/usr.bin/xlint/lint1/externs1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.125 src/usr.bin/xlint/lint1/externs1.h:1.126 --- src/usr.bin/xlint/lint1/externs1.h:1.125 Sat Jul 31 19:07:52 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sat Jul 31 19:12:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.125 2021/07/31 19:07:52 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.126 2021/07/31 19:12:35 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -131,8 +131,7 @@ void debug_leave(const char *); #define debug_node(tn, indent) debug_noop() #define debug_printf(...) debug_noop() #define debug_indent() debug_noop() -static inline void __printflike(1, 2) debug_step(const char *fmt, ...) {} -/*#define debug_step(...) debug_noop()*/ +#define debug_step(...) debug_noop() #define debug_indent() debug_noop() #define debug_indent_inc() debug_noop() #define debug_indent_dec() debug_noop()
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 19:07:52 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c err.c externs1.h func.c init.c lex.c main1.c Log Message: lint: clean up debug logging The calls to debug_step, unlike printf, don't need a trailing newline. Remove the debug_step0 macro and its relatives since lint already uses enough other features from C99 that it essentially requires this standard, which supports varargs macro arguments. Among these features are __func__ and printf("%zu"). In non-debug mode, do not evaluate the arguments of debug_step. Evaluating the arguments had caused an internal error when running the test op_shl_lp64. This is indeed a bug since initdecl should have initialized the type table for __uint128_t. This had been forgotten when support for __uint128_t was added in decl.c 1.69 from 2018-09-07. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.212 -r1.213 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.131 -r1.132 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.124 -r1.125 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.205 -r1.206 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.57 -r1.58 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.49 -r1.50 src/usr.bin/xlint/lint1/main1.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.212 src/usr.bin/xlint/lint1/decl.c:1.213 --- src/usr.bin/xlint/lint1/decl.c:1.212 Sat Jul 31 17:09:21 2021 +++ src/usr.bin/xlint/lint1/decl.c Sat Jul 31 19:07:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.212 2021/07/31 17:09:21 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.212 2021/07/31 17:09:21 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.213 2021/07/31 19:07:52 rillig Exp $"); #endif #include @@ -289,9 +289,8 @@ void add_type(type_t *tp) { tspec_t t; -#ifdef DEBUG - printf("%s: %s\n", __func__, type_name(tp)); -#endif + + debug_step("%s: %s", __func__, type_name(tp)); if (tp->t_typedef) { /* * something like "typedef int a; int a b;" @@ -801,9 +800,7 @@ dcs_merge_declaration_specifiers(void) l = dcs->d_rank_mod; /* SHORT, LONG or QUAD */ tp = dcs->d_type; -#ifdef DEBUG - printf("%s: %s\n", __func__, type_name(tp)); -#endif + debug_step("%s: %s", __func__, type_name(tp)); if (t == NOTSPEC && s == NOTSPEC && l == NOTSPEC && c == NOTSPEC && tp == NULL) dcs->d_notyp = true; @@ -3011,17 +3008,13 @@ check_usage(dinfo_t *di) mklwarn = lwarn; lwarn = LWARN_ALL; -#ifdef DEBUG - printf("%s, %d: >temp lwarn = %d\n", curr_pos.p_file, curr_pos.p_line, - lwarn); -#endif + debug_step("%s, %d: >temp lwarn = %d", + curr_pos.p_file, curr_pos.p_line, lwarn); for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) check_usage_sym(di->d_asm, sym); lwarn = mklwarn; -#ifdef DEBUG - printf("%s, %d: #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: err.c,v 1.131 2021/07/25 10:39:10 rillig Exp $"); +__RCSID("$NetBSD: err.c,v 1.132 2021/07/31 19:07:52 rillig Exp $"); #endif #include @@ -511,9 +511,7 @@ vwarning_at(int msgid, const pos_t *pos, if (ERR_ISSET(msgid, )) return; -#ifdef DEBUG - printf("%s: lwarn=%d msgid=%d\n", __func__, lwarn, msgid); -#endif + debug_step("%s: lwarn=%d msgid=%d", __func__, lwarn, msgid); if (lwarn == LWARN_NONE || lwarn == msgid) /* this warning is suppressed by a LINTED comment */ return; Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.124 src/usr.bin/xlint/lint1/externs1.h:1.125 --- src/usr.bin/xlint/lint1/externs1.h:1.124 Sat Jul 31 18:16:42 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sat Jul 31 19:07:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.124 2021/07/31 18:16:42 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.125 2021/07/31 19:07:52 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -123,27 +123,20 @@ void debug_indent_inc(void); void debug_indent_dec(void); void debug_enter(const char *); void debug_step(const char *fmt, ...) __printflike(1, 2); -#define debug_step0 debug_step -#define debug_step1 debug_step -#define debug_step2 debug_step void debug_leave(const char *); #define debug_enter() (debug_enter)(__func__) #define debug_leave() (debug_leave)(__func__) #else #define debug_noop() do { } while (false) -#define debug_node(tn, indent) debug_noop() -/* ARGSUSED */ -static inline void __printflike(1, 2) debug_printf(const char *fmt, ...) {} -#define debug_indent() debug_noop() -/* ARGSUSED */ +#define debug_node(tn, indent) debug_noop() +#define
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 18:16:42 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: Makefile externs1.h init.c tree.c Added Files: src/usr.bin/xlint/lint1: debug.c Log Message: lint: extract debug logging to separate file Lint currently has several different kinds of debug log: * The -DDEBUG log is controlled at compile time. * The -d command line options enables some other debug logging. * The -DYYDEBUG log for parsing is controlled at compile time. * The -y command line option only has an effect in -DYYDEBUG mode. Extracting the logging into a separate file is a first step towards unifying these logs and making the code for debug logging stand out less than the current #ifdef DEBUG. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.123 -r1.124 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.204 -r1.205 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.321 -r1.322 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.81 src/usr.bin/xlint/lint1/Makefile:1.82 --- src/usr.bin/xlint/lint1/Makefile:1.81 Sat Jul 31 17:09:21 2021 +++ src/usr.bin/xlint/lint1/Makefile Sat Jul 31 18:16:42 2021 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.81 2021/07/31 17:09:21 rillig Exp $ +# $NetBSD: Makefile,v 1.82 2021/07/31 18:16:42 rillig Exp $ .include PROG= lint1 SRCS= cgram.y \ - ckbool.c ckctype.c ckgetopt.c \ + ckbool.c ckctype.c ckgetopt.c debug.c \ decl.c emit.c emit1.c err.c func.c init.c inittyp.c lex.c \ main1.c mem.c mem1.c oper.c scan.l tree.c tyname.c Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.123 src/usr.bin/xlint/lint1/externs1.h:1.124 --- src/usr.bin/xlint/lint1/externs1.h:1.123 Sat Jul 31 17:09:21 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sat Jul 31 18:16:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.123 2021/07/31 17:09:21 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.124 2021/07/31 18:16:42 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -112,6 +112,42 @@ extern struct memory_block *expr_save_me extern void expr_restore_memory(struct memory_block *); /* + * debug.c + */ + +#ifdef DEBUG +void debug_node(const tnode_t *, int); +void debug_printf(const char *fmt, ...) __printflike(1, 2); +void debug_indent(void); +void debug_indent_inc(void); +void debug_indent_dec(void); +void debug_enter(const char *); +void debug_step(const char *fmt, ...) __printflike(1, 2); +#define debug_step0 debug_step +#define debug_step1 debug_step +#define debug_step2 debug_step +void debug_leave(const char *); +#define debug_enter() (debug_enter)(__func__) +#define debug_leave() (debug_leave)(__func__) +#else +#define debug_noop() do { } while (false) +#define debug_node(tn, indent) debug_noop() +/* ARGSUSED */ +static inline void __printflike(1, 2) debug_printf(const char *fmt, ...) {} +#define debug_indent() debug_noop() +/* ARGSUSED */ +static inline void __printflike(1, 2) debug_step(const char *fmt, ...) {} +#define debug_indent() debug_noop() +#define debug_indent_inc() debug_noop() +#define debug_indent_dec() debug_noop() +#define debug_enter() debug_noop() +#define debug_step0(fmt) debug_noop() +#define debug_step1(fmt, arg0) debug_noop() +#define debug_step2(fmt, arg1, arg2) debug_noop() +#define debug_leave() debug_noop() +#endif + +/* * err.c */ extern int nerr; @@ -235,11 +271,6 @@ extern void check_expr_misc(const tnode_ extern bool constant_addr(const tnode_t *, const sym_t **, ptrdiff_t *); extern strg_t *cat_strings(strg_t *, strg_t *); extern int64_t type_size_in_bits(const type_t *); -#ifdef DEBUG -extern void debug_node(const tnode_t *, int); -#else -#define debug_node(tn, indent) do { } while (false) -#endif /* * func.c Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.204 src/usr.bin/xlint/lint1/init.c:1.205 --- src/usr.bin/xlint/lint1/init.c:1.204 Sat Jul 31 11:03:04 2021 +++ src/usr.bin/xlint/lint1/init.c Sat Jul 31 18:16:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.204 2021/07/31 11:03:04 rillig Exp $ */ +/* $NetBSD: init.c,v 1.205 2021/07/31 18:16:42 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: init.c,v 1.204 2021/07/31 11:03:04 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.205 2021/07/31 18:16:42 rillig Exp $"); #endif #include @@ -172,74 +172,6 @@ struct initialization { }; -#ifdef DEBUG -static int debug_indentation = 0; -#endif - - -#ifdef DEBUG - -static void __printflike(1, 2) -debug_printf(const char *fmt, ...) -{ - va_list va; - - va_start(va,
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 17:09:21 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: Makefile cgram.y decl.c externs1.h Log Message: lint: add debugging output for the grammar tokens No functional change outside debug mode. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.351 -r1.352 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.211 -r1.212 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.122 -r1.123 src/usr.bin/xlint/lint1/externs1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.80 src/usr.bin/xlint/lint1/Makefile:1.81 --- src/usr.bin/xlint/lint1/Makefile:1.80 Sun Jul 25 22:14:36 2021 +++ src/usr.bin/xlint/lint1/Makefile Sat Jul 31 17:09:21 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.80 2021/07/25 22:14:36 rillig Exp $ +# $NetBSD: Makefile,v 1.81 2021/07/31 17:09:21 rillig Exp $ .include @@ -22,7 +22,7 @@ LOBJS.${PROG}+= ${SRCS:M*.l:.l=.ln} CPPFLAGS+= -DIS_LINT1 CPPFLAGS+= -I${.CURDIR} -CPPFLAGS+= ${DEBUG:D-DDEBUG} +CPPFLAGS+= ${DEBUG:D-DDEBUG -DYYDEBUG} COPTS.err.c+= ${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :} Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.351 src/usr.bin/xlint/lint1/cgram.y:1.352 --- src/usr.bin/xlint/lint1/cgram.y:1.351 Tue Jul 27 05:52:53 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sat Jul 31 17:09:21 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.351 2021/07/27 05:52:53 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.352 2021/07/31 17:09:21 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.351 2021/07/27 05:52:53 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.352 2021/07/31 17:09:21 rillig Exp $"); #endif #include @@ -122,6 +122,13 @@ anonymize(sym_t *s) s->s_styp = NULL; } +#if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON)) +#define YYSTYPE_TOSTRING cgram_to_string +#endif +#if defined(YYDEBUG) && defined(YYBISON) +#define YYPRINT cgram_print +#endif + %} %expect 150 @@ -349,6 +356,12 @@ anonymize(sym_t *s) %type do_while_expr %type func_declarator +%{ +#if defined(YYDEBUG) && defined(YYBISON) +static void cgram_print(FILE *, int, YYSTYPE); +#endif +%} + %% program: @@ -2116,6 +2129,47 @@ yyerror(const char *msg) return 0; } +#if (defined(YYDEBUG) && YYDEBUG > 0 && defined(YYBYACC)) \ +|| (defined(YYDEBUG) && defined(YYBISON)) +static const char * +cgram_to_string(int token, YYSTYPE val) +{ + static const char *tqual_name[] = { + "const", "volatile", "restrict", "_Thread_local" + }; + + switch (token) { + case T_INCDEC: + case T_MULTIPLICATIVE: + case T_ADDITIVE: + case T_SHIFT: + case T_RELATIONAL: + case T_EQUALITY: + case T_OPASSIGN: + return modtab[val.y_op].m_name; + case T_SCLASS: + return scl_name(val.y_scl); + case T_TYPE: + case T_STRUCT_OR_UNION: + return tspec_name(val.y_tspec); + case T_QUAL: + return tqual_name[val.y_tqual]; + case T_NAME: + return val.y_name->sb_name; + default: + return ""; + } +} +#endif + +#if defined(YYDEBUG) && defined(YYBISON) +static void +cgram_print(FILE *output, int token, YYSTYPE val) +{ + fprintf(output, "%s", cgram_to_string(token, val)); +} +#endif + static void cgram_declare(sym_t *decl, bool initflg, sbuf_t *renaming) { Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.211 src/usr.bin/xlint/lint1/decl.c:1.212 --- src/usr.bin/xlint/lint1/decl.c:1.211 Sat Jul 31 11:03:04 2021 +++ src/usr.bin/xlint/lint1/decl.c Sat Jul 31 17:09:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.211 2021/07/31 11:03:04 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.212 2021/07/31 17:09:21 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.211 2021/07/31 11:03:04 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.212 2021/07/31 17:09:21 rillig Exp $"); #endif #include @@ -134,7 +134,7 @@ initdecl(void) } /* Return the name of the "storage class" in the wider sense. */ -static const char * +const char * scl_name(scl_t scl) { static const char *const names[] = { Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.122 src/usr.bin/xlint/lint1/externs1.h:1.123 --- src/usr.bin/xlint/lint1/externs1.h:1.122 Sat Jul 31 11:03:04 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sat Jul 31 17:09:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.122 2021/07/31 11:03:04 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.123 2021/07/31 17:09:21 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -198,6 +198,7 @@ extern void
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 13:47:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: lex.c Log Message: lint: reduce indentation in 'search' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.56 src/usr.bin/xlint/lint1/lex.c:1.57 --- src/usr.bin/xlint/lint1/lex.c:1.56 Fri Jul 23 15:36:56 2021 +++ src/usr.bin/xlint/lint1/lex.c Sat Jul 31 13:47:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.56 2021/07/23 15:36:56 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.57 2021/07/31 13:47:19 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.56 2021/07/23 15:36:56 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.57 2021/07/31 13:47:19 rillig Exp $"); #endif #include @@ -450,17 +450,20 @@ lex_name(const char *yytext, size_t yyle static sym_t * search(sbuf_t *sb) { - sym_t *sym; + sym_t *sym; + const struct kwtab *kw; for (sym = symtab[sb->sb_hash]; sym != NULL; sym = sym->s_link) { - if (strcmp(sym->s_name, sb->sb_name) == 0) { - if (sym->s_keyword != NULL) { -const struct kwtab *kw = sym->s_keyword; -if (!kw->kw_attr || attron) - return sym; - } else if (!attron && sym->s_kind == symtyp) -return sym; - } + if (strcmp(sym->s_name, sb->sb_name) != 0) + continue; + kw = sym->s_keyword; + + if (kw != NULL && !kw->kw_attr) + return sym; + if (kw != NULL && attron) + return sym; + if (kw == NULL && !attron && sym->s_kind == symtyp) + return sym; } return NULL;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 11:37:54 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: in has_constant_member, don't reuse variables No functional change. To generate a diff of this commit: cvs rdiff -u -r1.320 -r1.321 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.320 src/usr.bin/xlint/lint1/tree.c:1.321 --- src/usr.bin/xlint/lint1/tree.c:1.320 Sat Jul 31 11:03:04 2021 +++ src/usr.bin/xlint/lint1/tree.c Sat Jul 31 11:37:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.320 2021/07/31 11:03:04 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.321 2021/07/31 11:37:53 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.320 2021/07/31 11:03:04 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.321 2021/07/31 11:37:53 rillig Exp $"); #endif #include @@ -2546,19 +2546,17 @@ merge_qualifiers(type_t *tp1, const type static bool has_constant_member(const type_t *tp) { - sym_t *m; - tspec_t t; + sym_t *m; - lint_assert((t = tp->t_tspec) == STRUCT || t == UNION); + lint_assert(is_struct_or_union(tp->t_tspec)); for (m = tp->t_str->sou_first_member; m != NULL; m = m->s_next) { - tp = m->s_type; - if (tp->t_const) + const type_t *mtp = m->s_type; + if (mtp->t_const) + return true; + if (is_struct_or_union(mtp->t_tspec) && + has_constant_member(mtp)) return true; - if ((t = tp->t_tspec) == STRUCT || t == UNION) { - if (has_constant_member(m->s_type)) -return true; - } } return false; }
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Jul 31 11:03:04 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c externs1.h func.c init.c lint1.h tree.c Log Message: lint: merge duplicate code for generating unqualified type This is a preparation for fixing the wrong warnings in msg_115.c. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.210 -r1.211 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.121 -r1.122 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.203 -r1.204 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.319 -r1.320 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.210 src/usr.bin/xlint/lint1/decl.c:1.211 --- src/usr.bin/xlint/lint1/decl.c:1.210 Sun Jul 25 22:14:36 2021 +++ src/usr.bin/xlint/lint1/decl.c Sat Jul 31 11:03:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.210 2021/07/25 22:14:36 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.211 2021/07/31 11:03:04 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.210 2021/07/25 22:14:36 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.211 2021/07/31 11:03:04 rillig Exp $"); #endif #include @@ -187,6 +187,27 @@ expr_dup_type(const type_t *tp) } /* + * Return the unqualified version of the type. The returned type is freed at + * the end of the current expression. + * + * See C99 6.2.5p25. + */ +type_t * +expr_unqualified_type(const type_t *tp) +{ + type_t *ntp; + + ntp = expr_zalloc(sizeof(*ntp)); + *ntp = *tp; + ntp->t_const = false; + ntp->t_volatile = false; + + /* TODO: deep-copy struct/union members; see msg_115.c */ + + return ntp; +} + +/* * Returns whether the argument is void or an incomplete array, * struct, union or enum type. */ Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.121 src/usr.bin/xlint/lint1/externs1.h:1.122 --- src/usr.bin/xlint/lint1/externs1.h:1.121 Sun Jul 25 22:14:36 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sat Jul 31 11:03:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.121 2021/07/25 22:14:36 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.122 2021/07/31 11:03:04 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -145,6 +145,7 @@ extern void initdecl(void); extern type_t *gettyp(tspec_t); extern type_t *dup_type(const type_t *); extern type_t *expr_dup_type(const type_t *); +extern type_t *expr_unqualified_type(const type_t *); extern bool is_incomplete(const type_t *); extern void setcomplete(type_t *, bool); extern void add_storage_class(scl_t); Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.115 src/usr.bin/xlint/lint1/func.c:1.116 --- src/usr.bin/xlint/lint1/func.c:1.115 Fri Jul 23 17:06:37 2021 +++ src/usr.bin/xlint/lint1/func.c Sat Jul 31 11:03:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.115 2021/07/23 17:06:37 rillig Exp $ */ +/* $NetBSD: func.c,v 1.116 2021/07/31 11:03:04 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.115 2021/07/23 17:06:37 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.116 2021/07/31 11:03:04 rillig Exp $"); #endif #include @@ -1091,8 +1091,7 @@ do_return(tnode_t *tn) /* Create a temporary node for the left side */ ln = expr_zalloc(sizeof(*ln)); ln->tn_op = NAME; - ln->tn_type = expr_dup_type(funcsym->s_type->t_subt); - ln->tn_type->t_const = false; + ln->tn_type = expr_unqualified_type(funcsym->s_type->t_subt); ln->tn_lvalue = true; ln->tn_sym = funcsym; /* better than nothing */ Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.203 src/usr.bin/xlint/lint1/init.c:1.204 --- src/usr.bin/xlint/lint1/init.c:1.203 Tue Jul 20 19:44:36 2021 +++ src/usr.bin/xlint/lint1/init.c Sat Jul 31 11:03:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.203 2021/07/20 19:44:36 rillig Exp $ */ +/* $NetBSD: init.c,v 1.204 2021/07/31 11:03:04 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: init.c,v 1.203 2021/07/20 19:44:36 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.204 2021/07/31 11:03:04 rillig Exp $"); #endif #include @@ -400,8 +400,7 @@ check_init_expr(const type_t *tp, sym_t tspec_t lt, rt; struct memory_block *tmem; - ltp = expr_dup_type(tp); - ltp->t_const = false; + ltp = expr_unqualified_type(tp); /* Create a temporary node for the left side. */ ln = expr_zalloc(sizeof(*ln)); @@ -900,8 +899,7 @@
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Jul 31 09:30:17 UTC 2021 Modified Files: src/usr.bin/make: Makefile make.h suff.c var.c src/usr.bin/make/filemon: filemon_ktrace.c Log Message: make: fix lint warnings The string functions from str.h are declared as 'static __unused' when compiled with GCC, but lint explicitly undefines __GCC__ during preprocessing. Therefore, make those functions inline, to prevent warnings that they are unused. The macro UNCONST is used in a few places, and (again) since lint undefines __GCC__, that macro expanded to a simple type cast, which lint warned about. To prevent this warning, implement UNCONST as a function that works everywhere and hides the type cast. In filemon_open, the code for closing F->in was obviously unreachable. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/Makefile cvs rdiff -u -r1.263 -r1.264 src/usr.bin/make/make.h cvs rdiff -u -r1.350 -r1.351 src/usr.bin/make/suff.c cvs rdiff -u -r1.944 -r1.945 src/usr.bin/make/var.c cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/filemon/filemon_ktrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/Makefile diff -u src/usr.bin/make/Makefile:1.115 src/usr.bin/make/Makefile:1.116 --- src/usr.bin/make/Makefile:1.115 Sun May 30 21:03:08 2021 +++ src/usr.bin/make/Makefile Sat Jul 31 09:30:17 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.115 2021/05/30 21:03:08 rillig Exp $ +# $NetBSD: Makefile,v 1.116 2021/07/31 09:30:17 rillig Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 PROG= make @@ -117,6 +117,7 @@ SUBDIR+= unit-tests .endif LINTFLAGS+= -T # strict bool mode, available since 2021-01-11 +LINTFLAGS+= -w # treat warnings as errors CLEANFILES+= *.o # for filemon objects COPTS.arch.c+= ${GCC_NO_FORMAT_TRUNCATION} Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.263 src/usr.bin/make/make.h:1.264 --- src/usr.bin/make/make.h:1.263 Mon Jun 21 10:33:11 2021 +++ src/usr.bin/make/make.h Sat Jul 31 09:30:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.263 2021/06/21 10:33:11 rillig Exp $ */ +/* $NetBSD: make.h,v 1.264 2021/07/31 09:30:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,14 @@ #endif #define MAKE_INLINE static inline MAKE_ATTR_UNUSED + +/* MAKE_STATIC marks a function that may or may not be inlined. */ +#if defined(lint) +/* As of 2021-07-31, NetBSD lint ignores __attribute__((unused)). */ +#define MAKE_STATIC MAKE_INLINE +#else #define MAKE_STATIC static MAKE_ATTR_UNUSED +#endif #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN) #include @@ -742,16 +749,13 @@ GNode_VarArchive(GNode *gn) { return GNo MAKE_INLINE const char * GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); } -#if defined(__GNUC__) && __STDC_VERSION__ >= 199901L -#define UNCONST(ptr) ({ \ -union __unconst { \ - const void *__cp; \ - void *__p; \ -} __d;\ -__d.__cp = ptr, __d.__p; }) -#else -#define UNCONST(ptr) (void *)(ptr) -#endif +MAKE_INLINE void * +UNCONST(const void *ptr) +{ + void *ret; + memcpy(, , sizeof(ret)); + return ret; +} /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ #include Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.350 src/usr.bin/make/suff.c:1.351 --- src/usr.bin/make/suff.c:1.350 Sun Apr 4 10:05:08 2021 +++ src/usr.bin/make/suff.c Sat Jul 31 09:30:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.350 2021/04/04 10:05:08 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.351 2021/07/31 09:30:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -115,7 +115,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.350 2021/04/04 10:05:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.351 2021/07/31 09:30:17 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -619,6 +619,7 @@ Suff_AddTransform(const char *name) /* TODO: Avoid the redundant parsing here. */ bool ok = ParseTransform(name, , ); assert(ok); + /* LINTED 129 *//* expression has null effect */ (void)ok; } Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.944 src/usr.bin/make/var.c:1.945 --- src/usr.bin/make/var.c:1.944 Sat Jul 31 00:17:04 2021 +++ src/usr.bin/make/var.c Sat Jul 31 09:30:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $ */ +/* $NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Jul 31 00:17:05 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: clean up ApplyModifier_Order No functional change. To generate a diff of this commit: cvs rdiff -u -r1.943 -r1.944 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.943 src/usr.bin/make/var.c:1.944 --- src/usr.bin/make/var.c:1.943 Fri Jul 30 23:35:38 2021 +++ src/usr.bin/make/var.c Sat Jul 31 00:17:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $ */ +/* $NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3355,32 +3355,26 @@ ApplyModifier_Order(const char **pp, Mod { const char *mod = *pp; Words words; - enum SortMode { - STR, NUM, SHUFFLE - } mode = STR; - enum SortDir { - ASC, DESC - } dir = ASC; + int (*cmp)(const void *, const void *) = NULL; if (IsDelimiter(mod[1], ch) || mod[1] == '\0') { - mode = STR; + cmp = str_cmp_asc; (*pp)++; } else if (IsDelimiter(mod[2], ch) || mod[2] == '\0') { if (mod[1] == 'n') - mode = NUM; + cmp = num_cmp_asc; else if (mod[1] == 'r') - dir = DESC; + cmp = str_cmp_desc; else if (mod[1] == 'x') - mode = SHUFFLE; + cmp = NULL; else goto bad; *pp += 2; } else if (IsDelimiter(mod[3], ch) || mod[3] == '\0') { if ((mod[1] == 'n' && mod[2] == 'r') || - (mod[1] == 'r' && mod[2] == 'n')) { - mode = NUM; - dir = DESC; - } else + (mod[1] == 'r' && mod[2] == 'n')) + cmp = num_cmp_desc; + else goto bad; *pp += 3; } else { @@ -3391,14 +3385,10 @@ ApplyModifier_Order(const char **pp, Mod return AMR_OK; words = Str_Words(ch->expr->value.str, false); - if (mode == SHUFFLE) + if (cmp == NULL) ShuffleStrings(words.words, words.len); - else if (mode == NUM) - qsort(words.words, words.len, sizeof words.words[0], - dir == ASC ? num_cmp_asc : num_cmp_desc); else - qsort(words.words, words.len, sizeof words.words[0], - dir == ASC ? str_cmp_asc : str_cmp_desc); + qsort(words.words, words.len, sizeof(words.words[0]), cmp); Expr_SetValueOwn(ch->expr, Words_JoinFree(words)); return AMR_OK;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 30 23:35:38 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: reword comment for ApplyModifier_Order To generate a diff of this commit: cvs rdiff -u -r1.942 -r1.943 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.942 src/usr.bin/make/var.c:1.943 --- src/usr.bin/make/var.c:1.942 Fri Jul 30 23:28:04 2021 +++ src/usr.bin/make/var.c Fri Jul 30 23:35:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $ */ +/* $NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3343,8 +3343,12 @@ ShuffleStrings(char **strs, size_t n) } } -/* :O (order ascending) or :Or (order descending) or :Ox (shuffle) or - * :On (numeric ascending) or :Onr or :Orn (numeric descending) +/* + * :O order ascending + * :Or order descending + * :Ox shuffle + * :On numeric ascending + * :Onr, :Orn numeric descending */ static ApplyModifierResult ApplyModifier_Order(const char **pp, ModChain *ch)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 30 23:28:04 UTC 2021 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-order-numeric.exp varmod-order-numeric.mk Log Message: make: handle parse errors in ':O' uniformly Previously, the error handling for the variable modifier ':O' differed depending on the exact variant and in some cases led to misleading or missing diagnostics. To generate a diff of this commit: cvs rdiff -u -r1.941 -r1.942 src/usr.bin/make/var.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-order-numeric.exp \ src/usr.bin/make/unit-tests/varmod-order-numeric.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.941 src/usr.bin/make/var.c:1.942 --- src/usr.bin/make/var.c:1.941 Fri Jul 30 22:19:51 2021 +++ src/usr.bin/make/var.c Fri Jul 30 23:28:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $ */ +/* $NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2045,7 +2045,7 @@ typedef struct Expr { * Chain 2 ends at the ':' between ${IND1} and ${IND2}. * Chain 3 starts with all modifiers from ${IND2}. * Chain 3 ends at the ':' after ${IND2}. - * Chain 1 continues with the the 2 modifiers ':O' and ':u'. + * Chain 1 continues with the 2 modifiers ':O' and ':u'. * Chain 1 ends at the final '}' of the expression. * * After such a chain ends, its properties no longer have any effect. @@ -3349,31 +3349,39 @@ ShuffleStrings(char **strs, size_t n) static ApplyModifierResult ApplyModifier_Order(const char **pp, ModChain *ch) { - const char *mod = (*pp)++; /* skip past the 'O' in any case */ + const char *mod = *pp; Words words; enum SortMode { - ASC, DESC, NUM_ASC, NUM_DESC, SHUFFLE - } mode; + STR, NUM, SHUFFLE + } mode = STR; + enum SortDir { + ASC, DESC + } dir = ASC; - if (IsDelimiter(mod[1], ch)) { - mode = ASC; - } else if (mod[1] == 'n') { - mode = NUM_ASC; - (*pp)++; - if (!IsDelimiter(mod[2], ch)) { - (*pp)++; - if (mod[2] == 'r') -mode = NUM_DESC; - } - } else if ((mod[1] == 'r' || mod[1] == 'x') && - IsDelimiter(mod[2], ch)) { + if (IsDelimiter(mod[1], ch) || mod[1] == '\0') { + mode = STR; (*pp)++; - mode = mod[1] == 'r' ? DESC : SHUFFLE; - } else if (mod[1] == 'r' && mod[2] == 'n') { - (*pp) += 2; - mode = NUM_DESC; - } else - return AMR_BAD; + } else if (IsDelimiter(mod[2], ch) || mod[2] == '\0') { + if (mod[1] == 'n') + mode = NUM; + else if (mod[1] == 'r') + dir = DESC; + else if (mod[1] == 'x') + mode = SHUFFLE; + else + goto bad; + *pp += 2; + } else if (IsDelimiter(mod[3], ch) || mod[3] == '\0') { + if ((mod[1] == 'n' && mod[2] == 'r') || + (mod[1] == 'r' && mod[2] == 'n')) { + mode = NUM; + dir = DESC; + } else + goto bad; + *pp += 3; + } else { + goto bad; + } if (!ModChain_ShouldEval(ch)) return AMR_OK; @@ -3381,15 +3389,19 @@ ApplyModifier_Order(const char **pp, Mod words = Str_Words(ch->expr->value.str, false); if (mode == SHUFFLE) ShuffleStrings(words.words, words.len); - else if (mode == NUM_ASC || mode == NUM_DESC) + else if (mode == NUM) qsort(words.words, words.len, sizeof words.words[0], - mode == NUM_ASC ? num_cmp_asc : num_cmp_desc); + dir == ASC ? num_cmp_asc : num_cmp_desc); else qsort(words.words, words.len, sizeof words.words[0], - mode == ASC ? str_cmp_asc : str_cmp_desc); + dir == ASC ? str_cmp_asc : str_cmp_desc); Expr_SetValueOwn(ch->expr, Words_JoinFree(words)); return AMR_OK; + +bad: + (*pp)++; + return AMR_BAD; } /* :? then : else */ Index: src/usr.bin/make/unit-tests/varmod-order-numeric.exp diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.2 src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.3 --- src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.2 Fri Jul 30 22:16:09 2021 +++ src/usr.bin/make/unit-tests/varmod-order-numeric.exp Fri Jul 30 23:28:04 2021 @@ -1,16 +1,20 @@ make: Bad modifier ":Oxn" for variable "NUMBERS" make: "varmod-order-numeric.mk" line 32: Malformed conditional (${NUMBERS:Oxn}) -make: Bad modifier ":typo" for variable "NUMBERS" -make: "varmod-order-numeric.mk" line 45: Malformed conditional (${NUMBERS:On_typo}) -make: "varmod-order-numeric.mk" line 54: Unknown modifier "_typo" -make: "varmod-order-numeric.mk" line 54: Malformed conditional (${NUMBERS:Onr_typo}) -make: "varmod-order-numeric.mk" line 63: Unknown modifier "_typo" -make:
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 30 22:19:51 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: merge duplicate code for sorting strings and numbers No functional change. To generate a diff of this commit: cvs rdiff -u -r1.940 -r1.941 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.940 src/usr.bin/make/var.c:1.941 --- src/usr.bin/make/var.c:1.940 Fri Jul 30 22:16:09 2021 +++ src/usr.bin/make/var.c Fri Jul 30 22:19:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $ */ +/* $NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3315,11 +3315,7 @@ num_cmp_asc(const void *sa, const void * static int num_cmp_desc(const void *sa, const void *sb) { - NUM_TYPE a, b; - - a = num_val(*(const char *const *)sa); - b = num_val(*(const char *const *)sb); - return (a > b) ? -1 : (b > a) ? 1 : 0; + return num_cmp_asc(sb, sa); } static int @@ -3331,7 +3327,7 @@ str_cmp_asc(const void *a, const void *b static int str_cmp_desc(const void *a, const void *b) { - return strcmp(*(const char *const *)b, *(const char *const *)a); + return str_cmp_asc(b, a); } static void
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 30 22:16:09 UTC 2021 Modified Files: src/usr.bin/make: make.1 var.c src/usr.bin/make/unit-tests: varmod-order-numeric.exp varmod-order-numeric.mk Log Message: make: fix typo in manual page, add more tests for the new ':On' To generate a diff of this commit: cvs rdiff -u -r1.297 -r1.298 src/usr.bin/make/make.1 cvs rdiff -u -r1.939 -r1.940 src/usr.bin/make/var.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-order-numeric.exp \ src/usr.bin/make/unit-tests/varmod-order-numeric.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.297 src/usr.bin/make/make.1:1.298 --- src/usr.bin/make/make.1:1.297 Fri Jul 30 19:55:22 2021 +++ src/usr.bin/make/make.1 Fri Jul 30 22:16:09 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.297 2021/07/30 19:55:22 sjg Exp $ +.\" $NetBSD: make.1,v 1.298 2021/07/30 22:16:09 rillig Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd July 30, 2020 +.Dd July 30, 2021 .Dt MAKE 1 .Os .Sh NAME Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.939 src/usr.bin/make/var.c:1.940 --- src/usr.bin/make/var.c:1.939 Fri Jul 30 19:55:22 2021 +++ src/usr.bin/make/var.c Fri Jul 30 22:16:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $ */ +/* $NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3311,7 +3311,7 @@ num_cmp_asc(const void *sa, const void * b = num_val(*(const char *const *)sb); return (a > b) ? 1 : (b > a) ? -1 : 0; } - + static int num_cmp_desc(const void *sa, const void *sb) { @@ -3321,7 +3321,7 @@ num_cmp_desc(const void *sa, const void b = num_val(*(const char *const *)sb); return (a > b) ? -1 : (b > a) ? 1 : 0; } - + static int str_cmp_asc(const void *a, const void *b) { Index: src/usr.bin/make/unit-tests/varmod-order-numeric.exp diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.1 src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.2 --- src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.1 Fri Jul 30 19:55:22 2021 +++ src/usr.bin/make/unit-tests/varmod-order-numeric.exp Fri Jul 30 22:16:09 2021 @@ -1 +1,16 @@ -exit status 0 +make: Bad modifier ":Oxn" for variable "NUMBERS" +make: "varmod-order-numeric.mk" line 32: Malformed conditional (${NUMBERS:Oxn}) +make: Bad modifier ":typo" for variable "NUMBERS" +make: "varmod-order-numeric.mk" line 45: Malformed conditional (${NUMBERS:On_typo}) +make: "varmod-order-numeric.mk" line 54: Unknown modifier "_typo" +make: "varmod-order-numeric.mk" line 54: Malformed conditional (${NUMBERS:Onr_typo}) +make: "varmod-order-numeric.mk" line 63: Unknown modifier "_typo" +make: "varmod-order-numeric.mk" line 63: Malformed conditional (${NUMBERS:Orn_typo}) +make: "varmod-order-numeric.mk" line 75: Missing argument for ".error" +make: "varmod-order-numeric.mk" line 83: Unknown modifier "r" +make: "varmod-order-numeric.mk" line 83: Malformed conditional (${NUMBERS:Onrr}) +make: Bad modifier ":Orrn" for variable "NUMBERS" +make: "varmod-order-numeric.mk" line 94: Malformed conditional (${NUMBERS:Orrn}) +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/varmod-order-numeric.mk diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.1 src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.2 --- src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.1 Fri Jul 30 19:55:22 2021 +++ src/usr.bin/make/unit-tests/varmod-order-numeric.mk Fri Jul 30 22:16:09 2021 @@ -1,18 +1,100 @@ -# $NetBSD: varmod-order-numeric.mk,v 1.1 2021/07/30 19:55:22 sjg Exp $ +# $NetBSD: varmod-order-numeric.mk,v 1.2 2021/07/30 22:16:09 rillig Exp $ # # Tests for the :On variable modifier, which returns the words, sorted in # ascending numeric order. -NUMBERS= 3 5 7 1 42 -42 1M 1k +# This list contains only 32-bit numbers since the make code needs to conform +# to C90, which does not provide integer types larger than 32 bit. It uses +# 'long long' by default, but that type is overridable if necessary. +# To get 53-bit integers even in C90, it would be possible to switch to +# 'double' instead, but that would allow floating-point numbers as well, which +# is out of scope for this variable modifier. +NUMBERS= 3 5 7 1 42 -42 5K -3m 1M 1k -2G -.if ${NUMBERS:On} != "-42
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Jul 30 19:55:22 UTC 2021 Modified Files: src/usr.bin/make: make.1 var.c src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: varmod-order-numeric.exp varmod-order-numeric.mk Log Message: Add :On for numeric sort Reviewed by: christos rillig To generate a diff of this commit: cvs rdiff -u -r1.296 -r1.297 src/usr.bin/make/make.1 cvs rdiff -u -r1.938 -r1.939 src/usr.bin/make/var.c cvs rdiff -u -r1.280 -r1.281 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-order-numeric.exp \ src/usr.bin/make/unit-tests/varmod-order-numeric.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.296 src/usr.bin/make/make.1:1.297 --- src/usr.bin/make/make.1:1.296 Thu Feb 4 21:42:46 2021 +++ src/usr.bin/make/make.1 Fri Jul 30 19:55:22 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.296 2021/02/04 21:42:46 rillig Exp $ +.\" $NetBSD: make.1,v 1.297 2021/07/30 19:55:22 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd December 22, 2020 +.Dd July 30, 2020 .Dt MAKE 1 .Os .Sh NAME @@ -1232,8 +1232,18 @@ but selects all words which do not match .Ar pattern . .It Cm \&:O Orders every word in variable alphabetically. +.It Cm \&:On +Orders every word in variable numerically. +A number followed by one of +.Ql K , +.Ql M +or +.Ql G +is multiplied by the appropriate factor. .It Cm \&:Or Orders every word in variable in reverse alphabetical order. +.It Cm \&:Orn +Orders every word in variable in reverse numerical order. .It Cm \&:Ox Shuffles the words in variable. The results will be different each time you are referring to the Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.938 src/usr.bin/make/var.c:1.939 --- src/usr.bin/make/var.c:1.938 Mon Jun 21 18:25:20 2021 +++ src/usr.bin/make/var.c Fri Jul 30 19:55:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.938 2021/06/21 18:25:20 rillig Exp $ */ +/* $NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.938 2021/06/21 18:25:20 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3272,6 +3272,56 @@ bad_modifier: return AMR_BAD; } +#ifndef NUM_TYPE +# define NUM_TYPE long long +#endif + +static NUM_TYPE +num_val(const char *s) +{ + NUM_TYPE val; + char *ep; + + val = strtoll(s, , 0); + if (ep != s) { + switch (*ep) { + case 'K': + case 'k': + val <<= 10; + break; + case 'M': + case 'm': + val <<= 20; + break; + case 'G': + case 'g': + val <<= 30; + break; + } + } + return val; +} + +static int +num_cmp_asc(const void *sa, const void *sb) +{ + NUM_TYPE a, b; + + a = num_val(*(const char *const *)sa); + b = num_val(*(const char *const *)sb); + return (a > b) ? 1 : (b > a) ? -1 : 0; +} + +static int +num_cmp_desc(const void *sa, const void *sb) +{ + NUM_TYPE a, b; + + a = num_val(*(const char *const *)sa); + b = num_val(*(const char *const *)sb); + return (a > b) ? -1 : (b > a) ? 1 : 0; +} + static int str_cmp_asc(const void *a, const void *b) { @@ -3297,22 +3347,35 @@ ShuffleStrings(char **strs, size_t n) } } -/* :O (order ascending) or :Or (order descending) or :Ox (shuffle) */ +/* :O (order ascending) or :Or (order descending) or :Ox (shuffle) or + * :On (numeric ascending) or :Onr or :Orn (numeric descending) + */ static ApplyModifierResult ApplyModifier_Order(const char **pp, ModChain *ch) { const char *mod = (*pp)++; /* skip past the 'O' in any case */ Words words; enum SortMode { - ASC, DESC, SHUFFLE + ASC, DESC, NUM_ASC, NUM_DESC, SHUFFLE } mode; if (IsDelimiter(mod[1], ch)) { mode = ASC; + } else if (mod[1] == 'n') { + mode = NUM_ASC; + (*pp)++; + if (!IsDelimiter(mod[2], ch)) { + (*pp)++; + if (mod[2] == 'r') +mode = NUM_DESC; + } } else if ((mod[1] == 'r' || mod[1] == 'x') && IsDelimiter(mod[2], ch)) { (*pp)++; mode = mod[1] == 'r' ? DESC : SHUFFLE; + } else if (mod[1] == 'r' && mod[2] == 'n') { + (*pp) += 2; + mode = NUM_DESC; } else return AMR_BAD; @@ -3322,6 +3385,9 @@ ApplyModifier_Order(const char **pp, Mod words = Str_Words(ch->expr->value.str, false); if (mode == SHUFFLE) ShuffleStrings(words.words, words.len); + else if (mode == NUM_ASC || mode == NUM_DESC) + qsort(words.words, words.len, sizeof words.words[0], + mode == NUM_ASC ? num_cmp_asc : num_cmp_desc); else qsort(words.words, words.len, sizeof
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jul 29 06:35:21 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: in TryParseNumber, reset errno as late as possible No functional change. To generate a diff of this commit: cvs rdiff -u -r1.269 -r1.270 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.269 src/usr.bin/make/cond.c:1.270 --- src/usr.bin/make/cond.c:1.269 Mon Jun 21 21:10:01 2021 +++ src/usr.bin/make/cond.c Thu Jul 29 06:35:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.269 2021/06/21 21:10:01 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.270 2021/07/29 06:35:20 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.269 2021/06/21 21:10:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.270 2021/07/29 06:35:20 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -376,12 +376,12 @@ TryParseNumber(const char *str, double * unsigned long ul_val; double dbl_val; - errno = 0; if (str[0] == '\0') { /* XXX: why is an empty string a number? */ *out_value = 0.0; return true; } + errno = 0; ul_val = strtoul(str, , str[1] == 'x' ? 16 : 10); if (*end == '\0' && errno != ERANGE) { *out_value = str[0] == '-' ? -(double)-ul_val : (double)ul_val;
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Jul 29 06:31:18 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-numeric.exp cond-cmp-numeric.mk Log Message: tests/make: test spaces around numbers in comparisons Just to see whether it is possible to write a conditional in the form ${ ${A} < ${B} :? ${A} : ${B} }, that is, with leading and trailing whitespace, to make it easier for humans to read the code. It's not possible, the result of this computation cannot be used in further numeric comparisons, at least not in .if directives. Leading space would work, but trailing space wouldn't. On the other hand, they would work in expressions of the form ${ ${A} < ${B} :? ... : ... } since in these, the condition is first expanded and then parsed. But that is an implementation detail that is not documented and it is also difficult to understand. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-cmp-numeric.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/unit-tests/cond-cmp-numeric.exp diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.5 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.6 --- src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.5 Thu Jan 21 23:32:28 2021 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric.exp Thu Jul 29 06:31:18 2021 @@ -6,6 +6,10 @@ CondParser_Eval: !(${:UNaN} == NaN) lhs = "NaN", rhs = "NaN", op = == CondParser_Eval: 123 ! 123 make: "cond-cmp-numeric.mk" line 34: Malformed conditional (123 ! 123) +CondParser_Eval: ${:U 123} < 124 +lhs = 123.00, rhs = 124.00, op = < +CondParser_Eval: ${:U123 } < 124 +make: "cond-cmp-numeric.mk" line 50: String comparison operator must be either == or != make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-cmp-numeric.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.4 src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.5 --- src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.4 Sun Nov 8 22:56:16 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric.mk Thu Jul 29 06:31:18 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-cmp-numeric.mk,v 1.4 2020/11/08 22:56:16 rillig Exp $ +# $NetBSD: cond-cmp-numeric.mk,v 1.5 2021/07/29 06:31:18 rillig Exp $ # # Tests for numeric comparisons in .if conditions. @@ -37,5 +37,21 @@ . error .endif +# Leading spaces are allowed for numbers. +# See EvalCompare and TryParseNumber. +.if ${:U 123} < 124 +.else +. error +.endif + +# Trailing spaces are NOT allowed for numbers. +# See EvalCompare and TryParseNumber. +# expect+1: String comparison operator must be either == or != +.if ${:U123 } < 124 +. error +.else +. error +.endif + all: @:;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jul 27 05:52:53 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: inline align_as in the grammar This saves 500 bytes in the resulting binary. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.350 -r1.351 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.350 src/usr.bin/xlint/lint1/cgram.y:1.351 --- src/usr.bin/xlint/lint1/cgram.y:1.350 Tue Jul 27 05:42:36 2021 +++ src/usr.bin/xlint/lint1/cgram.y Tue Jul 27 05:52:53 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.350 2021/07/27 05:42:36 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.351 2021/07/27 05:52:53 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.350 2021/07/27 05:42:36 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.351 2021/07/27 05:52:53 rillig Exp $"); #endif #include @@ -836,19 +836,14 @@ type_attribute_opt: type_attribute: /* See C11 6.7 declaration-specifiers */ gcc_attribute - /* TODO: c11ism */ - | T_ALIGNAS T_LPAREN align_as T_RPAREN + | T_ALIGNAS T_LPAREN type_specifier T_RPAREN /* C11 6.7.5 */ + | T_ALIGNAS T_LPAREN constant_expr T_RPAREN /* C11 6.7.5 */ | T_PACKED { addpacked(); } | T_NORETURN ; -align_as: /* See alignment-specifier in C11 6.7.5 */ - type_specifier - | constant_expr - ; - begin_type: /* empty */ { begin_type();
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jul 27 05:42:36 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: provide a direct link to the documentation No functional change. To generate a diff of this commit: cvs rdiff -u -r1.349 -r1.350 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.349 src/usr.bin/xlint/lint1/cgram.y:1.350 --- src/usr.bin/xlint/lint1/cgram.y:1.349 Mon Jul 26 18:10:14 2021 +++ src/usr.bin/xlint/lint1/cgram.y Tue Jul 27 05:42:36 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.349 2021/07/26 18:10:14 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.350 2021/07/27 05:42:36 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.349 2021/07/26 18:10:14 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.350 2021/07/27 05:42:36 rillig Exp $"); #endif #include @@ -1154,8 +1154,8 @@ type_qualifier_list: /* C99 6.7.5 */ ; /* - * For an explanation of 'notype' in the following rules, see the Bison - * manual, section 7.1 "Semantic Info in Token Kinds". + * For an explanation of 'notype' in the following rules, see + * https://www.gnu.org/software/bison/manual/bison.html#Semantic-Tokens. */ notype_init_declarators:
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jul 26 17:15:24 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: remove redundant associativity declarations Since cgram.y 1.325 from 2021-07-15, these are not needed anymore. Strangely, neither yacc nor Bison warned about this redundancy. No functional change, the grammar rules are the same as before. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.346 src/usr.bin/xlint/lint1/cgram.y:1.347 --- src/usr.bin/xlint/lint1/cgram.y:1.346 Sun Jul 25 21:31:01 2021 +++ src/usr.bin/xlint/lint1/cgram.y Mon Jul 26 17:15:24 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.346 2021/07/25 21:31:01 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.347 2021/07/26 17:15:24 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.346 2021/07/25 21:31:01 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.347 2021/07/26 17:15:24 rillig Exp $"); #endif #include @@ -260,8 +260,6 @@ anonymize(sym_t *s) %left T_THEN %left T_ELSE -%left T_COMMA -%right T_ASSIGN T_OPASSIGN %right T_QUEST T_COLON %left T_LOGOR %left T_LOGAND
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Mon Jul 26 16:22:24 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: ckbool.c Log Message: lint: make typeok_scalar_strict_bool simpler No functional change. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/lint1/ckbool.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/ckbool.c diff -u src/usr.bin/xlint/lint1/ckbool.c:1.7 src/usr.bin/xlint/lint1/ckbool.c:1.8 --- src/usr.bin/xlint/lint1/ckbool.c:1.7 Sun Jul 4 09:13:59 2021 +++ src/usr.bin/xlint/lint1/ckbool.c Mon Jul 26 16:22:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ckbool.c,v 1.7 2021/07/04 09:13:59 rillig Exp $ */ +/* $NetBSD: ckbool.c,v 1.8 2021/07/26 16:22:24 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: ckbool.c,v 1.7 2021/07/04 09:13:59 rillig Exp $"); +__RCSID("$NetBSD: ckbool.c,v 1.8 2021/07/26 16:22:24 rillig Exp $"); #endif #include @@ -181,7 +181,7 @@ typeok_scalar_strict_bool(op_t op, const if (!mp->m_takes_bool) { bool binary = mp->m_binary; - bool lbool = ln->tn_type->t_tspec == BOOL; + bool lbool = lt == BOOL; bool ok = true; if (!binary && lbool) { @@ -194,7 +194,7 @@ typeok_scalar_strict_bool(op_t op, const error(336, op_name(op)); ok = false; } - if (binary && rn->tn_type->t_tspec == BOOL) { + if (binary && rt == BOOL) { /* right operand of '%s' must not be bool */ error(337, op_name(op)); ok = false;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jul 25 22:14:37 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: Makefile decl.c externs1.h Removed Files: src/usr.bin/xlint/lint1: print.c Log Message: lint: move scl_name from print.c to decl.c It is only needed there. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r1.209 -r1.210 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.120 -r1.121 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.15 -r0 src/usr.bin/xlint/lint1/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/Makefile diff -u src/usr.bin/xlint/lint1/Makefile:1.79 src/usr.bin/xlint/lint1/Makefile:1.80 --- src/usr.bin/xlint/lint1/Makefile:1.79 Sat Jul 10 09:14:38 2021 +++ src/usr.bin/xlint/lint1/Makefile Sun Jul 25 22:14:36 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.79 2021/07/10 09:14:38 rillig Exp $ +# $NetBSD: Makefile,v 1.80 2021/07/25 22:14:36 rillig Exp $ .include @@ -6,7 +6,7 @@ PROG= lint1 SRCS= cgram.y \ ckbool.c ckctype.c ckgetopt.c \ decl.c emit.c emit1.c err.c func.c init.c inittyp.c lex.c \ - main1.c mem.c mem1.c oper.c print.c scan.l tree.c tyname.c + main1.c mem.c mem1.c oper.c scan.l tree.c tyname.c MAN= lint.7 YHEADER= Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.209 src/usr.bin/xlint/lint1/decl.c:1.210 --- src/usr.bin/xlint/lint1/decl.c:1.209 Fri Jul 23 16:48:48 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Jul 25 22:14:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.209 2021/07/23 16:48:48 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.210 2021/07/25 22:14:36 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.209 2021/07/23 16:48:48 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.210 2021/07/25 22:14:36 rillig Exp $"); #endif #include @@ -133,6 +133,20 @@ initdecl(void) typetab[UNSIGN].t_tspec = UNSIGN; } +/* Return the name of the "storage class" in the wider sense. */ +static const char * +scl_name(scl_t scl) +{ + static const char *const names[] = { + "none", "extern", "static", "auto", "register", "typedef", + "struct", "union", "enum", "member of struct", "member of union", + "compile-time constant", "abstract", "argument", + "prototype argument", "inline" + }; + + return names[scl]; +} + /* * Returns a shared type structure for arithmetic types and void. * Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.120 src/usr.bin/xlint/lint1/externs1.h:1.121 --- src/usr.bin/xlint/lint1/externs1.h:1.120 Tue Jul 20 19:44:36 2021 +++ src/usr.bin/xlint/lint1/externs1.h Sun Jul 25 22:14:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.120 2021/07/20 19:44:36 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.121 2021/07/25 22:14:36 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -340,11 +340,6 @@ extern void lex_unknown_character(int); extern int lex_input(void); /* - * print.c - */ -const char *scl_name(scl_t); - -/* * ckbool.c */ extern bool typeok_scalar_strict_bool(op_t, const mod_t *, int,
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jul 25 21:31:01 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: revert previous commit; it didn't improve readability No functional change. To generate a diff of this commit: cvs rdiff -u -r1.345 -r1.346 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.345 src/usr.bin/xlint/lint1/cgram.y:1.346 --- src/usr.bin/xlint/lint1/cgram.y:1.345 Sun Jul 25 19:57:22 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Jul 25 21:31:01 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.345 2021/07/25 19:57:22 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.346 2021/07/25 21:31:01 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.345 2021/07/25 19:57:22 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.346 2021/07/25 21:31:01 rillig Exp $"); #endif #include @@ -337,9 +337,7 @@ anonymize(sym_t *s) %type identifier_list %type type_name %type abstract_declaration -%type abstract_declarator_opt %type abstract_declarator -%type direct_abstract_declarator_opt %type direct_abstract_declarator %type abstract_decl_param_list %type vararg_parameter_type_list @@ -1373,36 +1371,30 @@ type_name: /* C99 6.7.6 */ ; abstract_declaration: /* specific to lint */ - begin_type_qualifier_list end_type abstract_declarator_opt { - $$ = declare_1_abstract($3); + begin_type_qualifier_list end_type { + $$ = declare_1_abstract(abstract_name()); + } + | begin_type_specifier_qualifier_list end_type { + $$ = declare_1_abstract(abstract_name()); } - | begin_type_specifier_qualifier_list end_type - abstract_declarator_opt { + | begin_type_qualifier_list end_type abstract_declarator { $$ = declare_1_abstract($3); } - ; - -abstract_declarator_opt: - /* empty */ { - $$ = abstract_name(); + | begin_type_specifier_qualifier_list end_type abstract_declarator { + $$ = declare_1_abstract($3); } - | abstract_declarator ; /* K 8.7, C90 ???, C99 6.7.6, C11 6.7.7 */ /* In K, abstract-declarator could be empty and was still simpler. */ abstract_declarator: - pointer direct_abstract_declarator_opt { - $$ = add_pointer($2, $1); + pointer { + $$ = add_pointer(abstract_name(), $1); } | direct_abstract_declarator - ; - -direct_abstract_declarator_opt: - /* empty */ { - $$ = abstract_name(); + | pointer direct_abstract_declarator { + $$ = add_pointer($2, $1); } - | direct_abstract_declarator ; /* K ---, C90 ???, C99 6.7.6, C11 6.7.7 */
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jul 25 19:57:22 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: merge duplicate code for abstract_declaration No functional change; same code coverage outside of cgram.y. To generate a diff of this commit: cvs rdiff -u -r1.344 -r1.345 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.344 src/usr.bin/xlint/lint1/cgram.y:1.345 --- src/usr.bin/xlint/lint1/cgram.y:1.344 Sun Jul 25 19:27:26 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Jul 25 19:57:22 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.344 2021/07/25 19:27:26 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.345 2021/07/25 19:57:22 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.344 2021/07/25 19:27:26 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.345 2021/07/25 19:57:22 rillig Exp $"); #endif #include @@ -337,7 +337,9 @@ anonymize(sym_t *s) %type identifier_list %type type_name %type abstract_declaration +%type abstract_declarator_opt %type abstract_declarator +%type direct_abstract_declarator_opt %type direct_abstract_declarator %type abstract_decl_param_list %type vararg_parameter_type_list @@ -1371,30 +1373,36 @@ type_name: /* C99 6.7.6 */ ; abstract_declaration: /* specific to lint */ - begin_type_qualifier_list end_type { - $$ = declare_1_abstract(abstract_name()); - } - | begin_type_specifier_qualifier_list end_type { - $$ = declare_1_abstract(abstract_name()); - } - | begin_type_qualifier_list end_type abstract_declarator { + begin_type_qualifier_list end_type abstract_declarator_opt { $$ = declare_1_abstract($3); } - | begin_type_specifier_qualifier_list end_type abstract_declarator { + | begin_type_specifier_qualifier_list end_type + abstract_declarator_opt { $$ = declare_1_abstract($3); } ; +abstract_declarator_opt: + /* empty */ { + $$ = abstract_name(); + } + | abstract_declarator + ; + /* K 8.7, C90 ???, C99 6.7.6, C11 6.7.7 */ /* In K, abstract-declarator could be empty and was still simpler. */ abstract_declarator: - pointer { - $$ = add_pointer(abstract_name(), $1); + pointer direct_abstract_declarator_opt { + $$ = add_pointer($2, $1); } | direct_abstract_declarator - | pointer direct_abstract_declarator { - $$ = add_pointer($2, $1); + ; + +direct_abstract_declarator_opt: + /* empty */ { + $$ = abstract_name(); } + | direct_abstract_declarator ; /* K ---, C90 ???, C99 6.7.6, C11 6.7.7 */
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jul 25 19:27:26 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: resolve conflicts in begin_type_specifier_qualifier_list The 9 shift/reduce conflicts were all internal to the grammar rule begin_type_specifier_qualifier_list. Previously, there were two possible ways to parse '__attribute__(()) const int': 1. '__attribute__(())' 'const int' 2. '__attribute__(()) const' 'int' Both ways would produce the same result since __attribute__ has almost no observable effects on the resulting type. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.343 src/usr.bin/xlint/lint1/cgram.y:1.344 --- src/usr.bin/xlint/lint1/cgram.y:1.343 Sun Jul 25 19:05:27 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Jul 25 19:27:26 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.343 2021/07/25 19:05:27 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.344 2021/07/25 19:27:26 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.343 2021/07/25 19:05:27 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.344 2021/07/25 19:27:26 rillig Exp $"); #endif #include @@ -124,7 +124,7 @@ anonymize(sym_t *s) %} -%expect 159 +%expect 150 %union { val_t *y_val; @@ -778,21 +778,24 @@ begin_type_declmods: /* see C99 6.7 */ ; begin_type_specifier_qualifier_list: /* see C11 6.7.2.1 */ + begin_type_specifier_qualifier_list_postfix + | type_attribute_list begin_type_specifier_qualifier_list_postfix + ; + +begin_type_specifier_qualifier_list_postfix: begin_type_typespec { add_type($1); } - /* TODO: shift/reduce conflict for type_attribute */ - | type_attribute begin_type_specifier_qualifier_list | begin_type_qualifier_list type_specifier { add_type($2); } - | begin_type_specifier_qualifier_list T_QUAL { + | begin_type_specifier_qualifier_list_postfix T_QUAL { add_qualifier($2); } - | begin_type_specifier_qualifier_list notype_type_specifier { + | begin_type_specifier_qualifier_list_postfix notype_type_specifier { add_type($2); } - | begin_type_specifier_qualifier_list type_attribute + | begin_type_specifier_qualifier_list_postfix type_attribute ; begin_type_typespec:
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jul 25 18:01:03 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: add citations for a few grammar rules No functional change. To generate a diff of this commit: cvs rdiff -u -r1.339 -r1.340 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.339 src/usr.bin/xlint/lint1/cgram.y:1.340 --- src/usr.bin/xlint/lint1/cgram.y:1.339 Sun Jul 25 17:40:04 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Jul 25 18:01:03 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.339 2021/07/25 17:40:04 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.340 2021/07/25 18:01:03 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.339 2021/07/25 17:40:04 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.340 2021/07/25 18:01:03 rillig Exp $"); #endif #include @@ -1366,7 +1366,7 @@ type_name: /* C99 6.7.6 */ } ; -abstract_declaration: +abstract_declaration: /* specific to lint */ begin_type_qualifier_list end_type { $$ = declare_1_abstract(abstract_name()); } @@ -1381,7 +1381,9 @@ abstract_declaration: } ; -abstract_declarator: /* C99 6.7.6 */ +/* K 8.7, C90 ???, C99 6.7.6, C11 6.7.7 */ +/* In K, abstract-declarator could be empty and was still simpler. */ +abstract_declarator: pointer { $$ = add_pointer(abstract_name(), $1); } @@ -1391,7 +1393,8 @@ abstract_declarator: /* C99 6.7.6 */ } ; -direct_abstract_declarator: /* C99 6.7.6 */ +/* K ---, C90 ???, C99 6.7.6, C11 6.7.7 */ +direct_abstract_declarator: T_LPAREN abstract_declarator T_RPAREN { $$ = $2; } @@ -1428,7 +1431,7 @@ direct_abstract_declarator: /* C99 6.7.6 | direct_abstract_declarator type_attribute_list ; -abstract_decl_param_list: +abstract_decl_param_list: /* specific to lint */ abstract_decl_lparen T_RPAREN type_attribute_opt { $$ = NULL; } @@ -1442,14 +1445,14 @@ abstract_decl_param_list: } ; -abstract_decl_lparen: +abstract_decl_lparen: /* specific to lint */ T_LPAREN { block_level++; begin_declaration_level(PROTO_ARG); } ; -vararg_parameter_type_list: +vararg_parameter_type_list: /* specific to lint */ parameter_type_list | parameter_type_list T_COMMA T_ELLIPSIS { dcs->d_vararg = true;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Jul 25 16:57:23 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: wrap overly long lines No functional change. To generate a diff of this commit: cvs rdiff -u -r1.337 -r1.338 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.337 src/usr.bin/xlint/lint1/cgram.y:1.338 --- src/usr.bin/xlint/lint1/cgram.y:1.337 Sun Jul 25 15:58:24 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Jul 25 16:57:23 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.337 2021/07/25 15:58:24 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.338 2021/07/25 16:57:23 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.337 2021/07/25 15:58:24 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.338 2021/07/25 16:57:23 rillig Exp $"); #endif #include @@ -608,7 +608,8 @@ unary_expression: | T_SIZEOF unary_expression { $$ = $2 == NULL ? NULL : build_sizeof($2->tn_type); if ($$ != NULL) - check_expr_misc($2, false, false, false, false, false, true); + check_expr_misc($2, + false, false, false, false, false, true); } | T_SIZEOF T_LPAREN type_name T_RPAREN { $$ = build_sizeof($3); @@ -971,7 +972,8 @@ struct_declaration: /* C99 6.7.2.1 */ error(249, "member without type"); $$ = NULL; } - | begin_type_specifier_qualifier_list end_type type_attribute_opt T_SEMI { + | begin_type_specifier_qualifier_list end_type type_attribute_opt + T_SEMI { symtyp = FVFT; if (!Sflag) /* anonymous struct/union members is a C9X feature */ @@ -1016,7 +1018,7 @@ type_struct_declarators: notype_struct_declarator: notype_declarator - | notype_declarator T_COLON constant_expr { /* C99 6.7.2.1 */ + | notype_declarator T_COLON constant_expr { /* C99 6.7.2.1 */ $$ = bitfield($1, to_int_constant($3, true)); } | { @@ -1107,7 +1109,8 @@ enumerator: /* C99 6.7.2.2 */ $$ = enumeration_constant($1, enumval, true); } | identifier_sym T_ASSIGN constant_expr { - $$ = enumeration_constant($1, to_int_constant($3, true), false); + $$ = enumeration_constant($1, to_int_constant($3, true), + false); } ; @@ -1258,9 +1261,9 @@ type_direct_declarator: ; /* - * The two distinct rules type_param_declarator and notype_param_declarator avoid a - * conflict in argument lists. A typename enclosed in parentheses is always - * treated as a typename, not an argument name. For example, after + * The two distinct rules type_param_declarator and notype_param_declarator + * avoid a conflict in argument lists. A typename enclosed in parentheses is + * always treated as a typename, not an argument name. For example, after * "typedef double a;", the declaration "f(int (a));" is interpreted as * "f(int (double));", not "f(int a);". */ @@ -1400,7 +1403,8 @@ direct_abstract_declarator: /* C99 6.7.6 $$ = add_array(abstract_name(), false, 0); } | T_LBRACK array_size T_RBRACK { - $$ = add_array(abstract_name(), true, to_int_constant($2, false)); + $$ = add_array(abstract_name(), true, + to_int_constant($2, false)); } | type_attribute direct_abstract_declarator { $$ = $2; @@ -1419,7 +1423,8 @@ direct_abstract_declarator: /* C99 6.7.6 end_declaration_level(); block_level--; } - | direct_abstract_declarator abstract_decl_param_list asm_or_symbolrename_opt { + | direct_abstract_declarator abstract_decl_param_list + asm_or_symbolrename_opt { $$ = add_function(symbolrename($1, $3), $2); end_declaration_level(); block_level--; @@ -1431,7 +1436,8 @@ abstract_decl_param_list: abstract_decl_lparen T_RPAREN type_attribute_opt { $$ = NULL; } - | abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt { + | abstract_decl_lparen vararg_parameter_type_list T_RPAREN + type_attribute_opt { dcs->d_proto = true; $$ = $2; }
CVS commit: src/usr.bin/systat
Module Name:src Committed By: simonb Date: Sat Jul 24 13:42:05 UTC 2021 Modified Files: src/usr.bin/systat: vmstat.c Log Message: Instead of getting an estimate of the number of kernel buffers, allocating memory for them, requesting all the metadata contents of these buffers (and repeating in the unlikely case of the number of buffers increasing too much since the estimate) and then straight away throwing all the contents out just to count how many buffers there were, just get the initial estimate from the kernel and subtract the slop. Reduces system CPU usage of "systat vm" by approx 80% for any system with a reasonable number of buffers. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/usr.bin/systat/vmstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/systat/vmstat.c diff -u src/usr.bin/systat/vmstat.c:1.88 src/usr.bin/systat/vmstat.c:1.89 --- src/usr.bin/systat/vmstat.c:1.88 Mon Mar 2 09:50:12 2020 +++ src/usr.bin/systat/vmstat.c Sat Jul 24 13:42:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vmstat.c,v 1.88 2020/03/02 09:50:12 mrg Exp $ */ +/* $NetBSD: vmstat.c,v 1.89 2021/07/24 13:42:05 simonb Exp $ */ /*- * Copyright (c) 1983, 1989, 1992, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; #endif -__RCSID("$NetBSD: vmstat.c,v 1.88 2020/03/02 09:50:12 mrg Exp $"); +__RCSID("$NetBSD: vmstat.c,v 1.89 2021/07/24 13:42:05 simonb Exp $"); #endif /* not lint */ /* @@ -481,10 +481,8 @@ showvmstat(void) static int relabel = 0; static int last_disks = 0; static u_long bufmem; - struct buf_sysctl *buffers; int mib[6]; size_t size; - int extraslop = 0; if (relabel) { labelvmstat(); @@ -528,14 +526,12 @@ showvmstat(void) /* Get number of metadata buffers */ size = 0; - buffers = NULL; mib[0] = CTL_KERN; mib[1] = KERN_BUF; mib[2] = KERN_BUF_ALL; mib[3] = KERN_BUF_ALL; mib[4] = (int)sizeof(struct buf_sysctl); mib[5] = INT_MAX; /* we want them all */ -again: if (sysctl(mib, 6, NULL, , NULL, 0) < 0) { error("can't get buffers size: %s\n", strerror(errno)); return; @@ -544,23 +540,8 @@ again: error("buffers size is zero: %s\n", strerror(errno)); return; } - size += extraslop * sizeof(struct buf_sysctl); - buffers = malloc(size); - if (buffers == NULL) { - error("can't allocate buffers: %s\n", strerror(errno)); - return; - } - if (sysctl(mib, 6, buffers, , NULL, 0) < 0) { - free(buffers); - if (extraslop < 1000) { - extraslop += 100; - goto again; - } - error("can't get buffers: %s\n", strerror(errno)); - return; - } - free(buffers); /* XXX there must be a better way! */ nbuf = size / sizeof(struct buf_sysctl); + nbuf -= KERN_BUFSLOP; putint((int) (bufmem / 1024), MEMROW + 3, MEMCOL + 5, 12); putint((int) ((bufmem * 100) + 0.5) / s.uvmexp.pagesize / s.uvmexp.npages,
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Jul 23 17:06:37 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: func.c lint1.h Log Message: lint: rename cstk_t to control_statement Rename the variables as well. Their previous name 'ci' was not easy to understand, the 'i' may have meant 'stack item'. The new name 'cs' simply means 'control statement'. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.114 src/usr.bin/xlint/lint1/func.c:1.115 --- src/usr.bin/xlint/lint1/func.c:1.114 Tue Jul 20 19:35:53 2021 +++ src/usr.bin/xlint/lint1/func.c Fri Jul 23 17:06:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.114 2021/07/20 19:35:53 rillig Exp $ */ +/* $NetBSD: func.c,v 1.115 2021/07/23 17:06:37 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.114 2021/07/20 19:35:53 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.115 2021/07/23 17:06:37 rillig Exp $"); #endif #include @@ -76,7 +76,7 @@ bool warn_about_unreachable; bool seen_fallthrough; /* The innermost control statement */ -cstk_t *cstmt; +control_statement *cstmt; /* * Number of arguments which will be checked for usage in following @@ -155,12 +155,12 @@ bool quadflg; void begin_control_statement(control_statement_kind kind) { - cstk_t *ci; + control_statement *cs; - ci = xcalloc(1, sizeof(*ci)); - ci->c_kind = kind; - ci->c_surrounding = cstmt; - cstmt = ci; + cs = xcalloc(1, sizeof(*cs)); + cs->c_kind = kind; + cs->c_surrounding = cstmt; + cstmt = cs; } /* @@ -169,7 +169,7 @@ begin_control_statement(control_statemen void end_control_statement(control_statement_kind kind) { - cstk_t *ci; + control_statement *cs; case_label_t *cl, *next; lint_assert(cstmt != NULL); @@ -177,16 +177,16 @@ end_control_statement(control_statement_ while (cstmt->c_kind != kind) cstmt = cstmt->c_surrounding; - ci = cstmt; - cstmt = ci->c_surrounding; + cs = cstmt; + cstmt = cs->c_surrounding; - for (cl = ci->c_case_labels; cl != NULL; cl = next) { + for (cl = cs->c_case_labels; cl != NULL; cl = next) { next = cl->cl_next; free(cl); } - free(ci->c_switch_type); - free(ci); + free(cs->c_switch_type); + free(cs); } static void @@ -465,32 +465,32 @@ check_case_label_bitand(const tnode_t *c } static void -check_case_label_enum(const tnode_t *tn, const cstk_t *ci) +check_case_label_enum(const tnode_t *tn, const control_statement *cs) { /* similar to typeok_enum in tree.c */ - if (!(tn->tn_type->t_is_enum || ci->c_switch_type->t_is_enum)) + if (!(tn->tn_type->t_is_enum || cs->c_switch_type->t_is_enum)) return; - if (tn->tn_type->t_is_enum && ci->c_switch_type->t_is_enum && - tn->tn_type->t_enum == ci->c_switch_type->t_enum) + if (tn->tn_type->t_is_enum && cs->c_switch_type->t_is_enum && + tn->tn_type->t_enum == cs->c_switch_type->t_enum) return; #if 0 /* not yet ready, see msg_130.c */ /* enum type mismatch: '%s' '%s' '%s' */ - warning(130, type_name(ci->c_switch_type), op_name(EQ), + warning(130, type_name(cs->c_switch_type), op_name(EQ), type_name(tn->tn_type)); #endif } static void -check_case_label(tnode_t *tn, cstk_t *ci) +check_case_label(tnode_t *tn, control_statement *cs) { case_label_t *cl; val_t *v; val_t nv; tspec_t t; - if (ci == NULL) { + if (cs == NULL) { /* case not in switch */ error(195); return; @@ -508,10 +508,10 @@ check_case_label(tnode_t *tn, cstk_t *ci return; } - check_case_label_bitand(tn, ci->c_switch_expr); - check_case_label_enum(tn, ci); + check_case_label_bitand(tn, cs->c_switch_expr); + check_case_label_enum(tn, cs); - lint_assert(ci->c_switch_type != NULL); + lint_assert(cs->c_switch_type != NULL); if (reached && !seen_fallthrough) { if (hflag) @@ -533,11 +533,11 @@ check_case_label(tnode_t *tn, cstk_t *ci */ v = constant(tn, true); (void)memset(, 0, sizeof(nv)); - convert_constant(CASE, 0, ci->c_switch_type, , v); + convert_constant(CASE, 0, cs->c_switch_type, , v); free(v); /* look if we had this value already */ - for (cl = ci->c_case_labels; cl != NULL; cl = cl->cl_next) { + for (cl = cs->c_case_labels; cl != NULL; cl = cl->cl_next) { if (cl->cl_val.v_quad == nv.v_quad) break; } @@ -553,21 +553,21 @@ check_case_label(tnode_t *tn, cstk_t *ci /* append the value to the list of case values */ cl = xcalloc(1, sizeof(*cl)); cl->cl_val = nv; - cl->cl_next = ci->c_case_labels; - ci->c_case_labels = cl; + cl->cl_next = cs->c_case_labels; + cs->c_case_labels = cl; } } void case_label(tnode_t *tn) { - cstk_t *ci; +
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Jul 23 16:48:48 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c lint1.h Log Message: lint: remove a few unnecessary abbreviations No functional change. To generate a diff of this commit: cvs rdiff -u -r1.208 -r1.209 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.208 src/usr.bin/xlint/lint1/decl.c:1.209 --- src/usr.bin/xlint/lint1/decl.c:1.208 Fri Jul 23 16:43:11 2021 +++ src/usr.bin/xlint/lint1/decl.c Fri Jul 23 16:48:48 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.208 2021/07/23 16:43:11 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.209 2021/07/23 16:48:48 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.208 2021/07/23 16:43:11 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.209 2021/07/23 16:48:48 rillig Exp $"); #endif #include @@ -236,11 +236,7 @@ add_storage_class(scl_t sc) if (dcs->d_scl == NOSCL) { dcs->d_scl = sc; } else { - /* - * multiple storage classes. An error will be reported in - * end_type(). - */ - dcs->d_mscl = true; + dcs->d_multiple_storage_classes = true; } } @@ -284,11 +280,7 @@ add_type(type_t *tp) */ if (dcs->d_type != NULL || dcs->d_abstract_type != NOTSPEC || dcs->d_rank_mod != NOTSPEC || dcs->d_sign_mod != NOTSPEC) { - /* - * remember that an error must be reported in - * end_type(). - */ - dcs->d_terr = true; + dcs->d_invalid_type_combination = true; dcs->d_abstract_type = NOTSPEC; dcs->d_sign_mod = NOTSPEC; dcs->d_rank_mod = NOTSPEC; @@ -302,7 +294,7 @@ add_type(type_t *tp) * something like "struct a int" * struct/union/enum with anything else is not allowed */ - dcs->d_terr = true; + dcs->d_invalid_type_combination = true; return; } @@ -341,11 +333,8 @@ add_type(type_t *tp) * dcs->d_sign_mod */ if (dcs->d_sign_mod != NOTSPEC) - /* - * more than one "signed" and/or "unsigned"; print - * an error in end_type() - */ - dcs->d_terr = true; + /* more than one "signed" and/or "unsigned" */ + dcs->d_invalid_type_combination = true; dcs->d_sign_mod = t; } else if (t == SHORT || t == LONG || t == QUAD) { /* @@ -353,18 +342,17 @@ add_type(type_t *tp) * dcs->d_rank_mod */ if (dcs->d_rank_mod != NOTSPEC) - /* more than one, print error in end_type() */ - dcs->d_terr = true; + dcs->d_invalid_type_combination = true; dcs->d_rank_mod = t; } else if (t == FLOAT || t == DOUBLE) { if (dcs->d_rank_mod == NOTSPEC || dcs->d_rank_mod == LONG) { if (dcs->d_complex_mod != NOTSPEC || (t == FLOAT && dcs->d_rank_mod == LONG)) -dcs->d_terr = true; +dcs->d_invalid_type_combination = true; dcs->d_complex_mod = t; } else { if (dcs->d_abstract_type != NOTSPEC) -dcs->d_terr = true; +dcs->d_invalid_type_combination = true; dcs->d_abstract_type = t; } } else if (t == PTR) { @@ -375,8 +363,7 @@ add_type(type_t *tp) * or "_Complex" in dcs->d_abstract_type */ if (dcs->d_abstract_type != NOTSPEC) - /* more than one, print error in end_type() */ - dcs->d_terr = true; + dcs->d_invalid_type_combination = true; dcs->d_abstract_type = t; } } @@ -491,7 +478,7 @@ tdeferr(type_t *td, tspec_t t) /* Anything other is not accepted. */ - dcs->d_terr = true; + dcs->d_invalid_type_combination = true; return td; } @@ -738,8 +725,8 @@ begin_type(void) dcs->d_const = false; dcs->d_volatile = false; dcs->d_inline = false; - dcs->d_mscl = false; - dcs->d_terr = false; + dcs->d_multiple_storage_classes = false; + dcs->d_invalid_type_combination = false; dcs->d_nonempty_decl = false; dcs->d_notyp = false; } @@ -801,7 +788,7 @@ dcs_merge_declaration_specifiers(void) if (s == NOTSPEC && t == INT) s = SIGNED; if (l != NOTSPEC && t == CHAR) { - dcs->d_terr = true; + dcs->d_invalid_type_combination = true; l = NOTSPEC; } if (l == LONG && t == FLOAT) { @@ -825,7 +812,7 @@ dcs_merge_declaration_specifiers(void) } if (t != INT && t != CHAR && (s != NOTSPEC || l != NOTSPEC)) { - dcs->d_terr = true; + dcs->d_invalid_type_combination = true; l = s = NOTSPEC; } if (l != NOTSPEC) @@ -845,11 +832,11 @@ end_type(void) dcs_merge_declaration_specifiers(); - if (dcs->d_mscl) { + if (dcs->d_multiple_storage_classes) { /* only one storage class allowed */ error(7); } - if (dcs->d_terr) { + if (dcs->d_invalid_type_combination) { /* illegal type combination */ error(4); } Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.116 src/usr.bin/xlint/lint1/lint1.h:1.117 ---
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Jul 23 16:43:11 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c lint1.h Log Message: lint: make offset and alignment positive numbers There's no use case for negative alignment or offsets in structures. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.207 -r1.208 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.207 src/usr.bin/xlint/lint1/decl.c:1.208 --- src/usr.bin/xlint/lint1/decl.c:1.207 Thu Jul 15 23:54:22 2021 +++ src/usr.bin/xlint/lint1/decl.c Fri Jul 23 16:43:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.207 2021/07/15 23:54:22 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.208 2021/07/23 16:43:11 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.207 2021/07/15 23:54:22 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.208 2021/07/23 16:43:11 rillig Exp $"); #endif #include @@ -64,7 +64,7 @@ dinfo_t *dcs; static type_t *tdeferr(type_t *, tspec_t); static void settdsym(type_t *, sym_t *); -static void align(int, int); +static void align(u_int, u_int); static sym_t *newtag(sym_t *, scl_t, bool, bool); static bool eqargs(const type_t *, const type_t *, bool *); static bool mnoarg(const type_t *, bool *); @@ -1154,7 +1154,7 @@ declarator_1_struct_union(sym_t *dsym) type_t *tp; tspec_t t; int sz; - int o = 0; /* Appease GCC */ + u_int o = 0; /* Appease GCC */ lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU); @@ -1231,9 +1231,9 @@ declarator_1_struct_union(sym_t *dsym) * al contains the required alignment, len the length of a bit-field. */ static void -align(int al, int len) +align(u_int al, u_int len) { - int no; + u_int no; /* * The alignment of the current element becomes the alignment of Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.115 src/usr.bin/xlint/lint1/lint1.h:1.116 --- src/usr.bin/xlint/lint1/lint1.h:1.115 Thu Jul 15 18:13:25 2021 +++ src/usr.bin/xlint/lint1/lint1.h Fri Jul 23 16:43:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.115 2021/07/15 18:13:25 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.116 2021/07/23 16:43:11 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -360,8 +360,8 @@ typedef struct dinfo { type_t *d_type; /* after end_type() pointer to the type used for all declarators */ sym_t *d_redeclared_symbol; - int d_offset; /* offset of next structure member */ - int d_sou_align_in_bits; /* alignment required for current + u_int d_offset; /* offset of next structure member */ + u_int d_sou_align_in_bits; /* alignment required for current * structure */ scl_t d_ctx; /* context of declaration */ bool d_const : 1; /* const in declaration specifiers */
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Jul 23 15:36:57 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: lex.c Log Message: lint: write canonical form of keywords For keywords that have a single spelling variant (such as __packed), write this form in the source, to make it searchable. This also avoids a few calls to malloc. Previously, some keywords had leading underscores and some hadn't, this was inconsistent. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.55 src/usr.bin/xlint/lint1/lex.c:1.56 --- src/usr.bin/xlint/lint1/lex.c:1.55 Sun Jul 11 19:24:41 2021 +++ src/usr.bin/xlint/lint1/lex.c Fri Jul 23 15:36:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.55 2021/07/11 19:24:41 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.56 2021/07/23 15:36:56 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.55 2021/07/11 19:24:41 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.56 2021/07/23 15:36:56 rillig Exp $"); #endif #include @@ -134,34 +134,26 @@ static struct kwtab { bool kw_attr : 1; /* GCC attribute, keyword */ u_int kw_deco : 3; /* 1 = name, 2 = __name, 4 = __name__ */ } kwtab[] = { -#ifdef INT128_SIZE - kwdef_type( "__int128_t", INT128, 0,1,0,0,1), - kwdef_type( "__uint128_t", UINT128, 0,1,0,0,1), -#endif - kwdef_tqual( "__thread", THREAD, 0,0,1,0,1), + kwdef_gcc_attr( "alias", T_AT_ALIAS), kwdef_keyword( "_Alignas", T_ALIGNAS), kwdef_keyword( "_Alignof", T_ALIGNOF), - kwdef_type( "_Bool", BOOL, 0,1,0,0,1), - kwdef_type( "_Complex", COMPLEX, 0,1,0,0,1), - kwdef_token( "_Generic", T_GENERIC, 0,1,0,0,1), - kwdef_token( "_Noreturn", T_NORETURN, 0,1,0,0,1), - kwdef_tqual( "_Thread_local", THREAD, 0,1,0,0,1), - kwdef_gcc_attr( "alias", T_AT_ALIAS), kwdef_gcc_attr( "aligned", T_AT_ALIGNED), - kwdef_token( "alignof", T_ALIGNOF, 0,0,0,0,4), + kwdef_token( "__alignof__", T_ALIGNOF, 0,0,0,0,1), kwdef_gcc_attr( "alloc_size", T_AT_ALLOC_SIZE), kwdef_gcc_attr( "always_inline",T_AT_ALWAYS_INLINE), kwdef_token( "asm", T_ASM, 0,0,1,0,7), kwdef_token( "attribute", T_ATTRIBUTE, 0,0,1,0,6), kwdef_sclass( "auto", AUTO, 0,0,0,0,1), + kwdef_type( "_Bool", BOOL, 0,1,0,0,1), kwdef_gcc_attr( "bounded", T_AT_BOUNDED), kwdef_keyword( "break", T_BREAK), kwdef_gcc_attr( "buffer", T_AT_BUFFER), - kwdef_token( "builtin_offsetof", T_BUILTIN_OFFSETOF, 0,0,1,0,2), + kwdef_token( "__builtin_offsetof", T_BUILTIN_OFFSETOF, 0,0,1,0,1), kwdef_keyword( "case", T_CASE), kwdef_type( "char", CHAR, 0,0,0,0,1), kwdef_gcc_attr( "cold", T_AT_COLD), kwdef_gcc_attr( "common", T_AT_COMMON), + kwdef_type( "_Complex", COMPLEX, 0,1,0,0,1), kwdef_tqual( "const", CONST, 1,0,0,0,7), kwdef_gcc_attr( "constructor", T_AT_CONSTRUCTOR), kwdef_keyword( "continue", T_CONTINUE), @@ -172,21 +164,25 @@ static struct kwtab { kwdef_type( "double", DOUBLE, 0,0,0,0,1), kwdef_keyword( "else", T_ELSE), kwdef_keyword( "enum", T_ENUM), - kwdef_token( "extension", T_EXTENSION, 0,0,1,0,4), + kwdef_token( "__extension__",T_EXTENSION, 0,0,1,0,1), kwdef_sclass( "extern", EXTERN, 0,0,0,0,1), kwdef_gcc_attr( "fallthrough", T_AT_FALLTHROUGH), kwdef_type( "float", FLOAT, 0,0,0,0,1), kwdef_keyword( "for", T_FOR), kwdef_gcc_attr( "format", T_AT_FORMAT), kwdef_gcc_attr( "format_arg", T_AT_FORMAT_ARG), + kwdef_token( "_Generic", T_GENERIC, 0,1,0,0,1), kwdef_gcc_attr( "gnu_inline", T_AT_GNU_INLINE), kwdef_gcc_attr( "gnu_printf", T_AT_FORMAT_GNU_PRINTF), kwdef_keyword( "goto", T_GOTO), kwdef_gcc_attr( "hot", T_AT_HOT), kwdef_keyword( "if", T_IF), - kwdef_token( "imag", T_IMAG, 0,0,1,0,4), + kwdef_token( "__imag__", T_IMAG, 0,0,1,0,1), kwdef_sclass( "inline", INLINE, 0,1,0,0,7), kwdef_type( "int", INT, 0,0,0,0,1), +#ifdef INT128_SIZE + kwdef_type( "__int128_t", INT128, 0,1,0,0,1), +#endif kwdef_type( "long", LONG, 0,0,0,0,1), kwdef_gcc_attr( "malloc", T_AT_MALLOC), kwdef_gcc_attr( "may_alias", T_AT_MAY_ALIAS), @@ -197,15 +193,16 @@ static struct kwtab { kwdef_gcc_attr( "noinline", T_AT_NOINLINE), kwdef_gcc_attr( "nonnull", T_AT_NONNULL), kwdef_gcc_attr( "nonstring", T_AT_NONSTRING), + kwdef_token( "_Noreturn", T_NORETURN, 0,1,0,0,1), kwdef_gcc_attr( "noreturn", T_AT_NORETURN), kwdef_gcc_attr( "nothrow", T_AT_NOTHROW), kwdef_gcc_attr( "optimize", T_AT_OPTIMIZE), kwdef_gcc_attr( "packed", T_AT_PACKED), - kwdef_token( "packed", T_PACKED, 0,0,0,0,2), + kwdef_token( "__packed", T_PACKED, 0,0,0,0,1), kwdef_gcc_attr( "pcs", T_AT_PCS), kwdef_gcc_attr( "printf", T_AT_FORMAT_PRINTF), kwdef_gcc_attr(
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Fri Jul 23 15:14:49 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: move single semicolon to external_declaration This aligns more closely with the grammar from GCC's parser. The global cleanup from the grammar rule 'external_declaration: top_level_declaration' is not performed anymore, which doesn't matter since there is nothing to clean up after a single semicolon. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.334 -r1.335 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.334 src/usr.bin/xlint/lint1/cgram.y:1.335 --- src/usr.bin/xlint/lint1/cgram.y:1.334 Wed Jul 21 21:24:45 2021 +++ src/usr.bin/xlint/lint1/cgram.y Fri Jul 23 15:14:49 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.334 2021/07/21 21:24:45 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.335 2021/07/23 15:14:49 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.334 2021/07/21 21:24:45 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.335 2021/07/23 15:14:49 rillig Exp $"); #endif #include @@ -1870,8 +1870,7 @@ translation_unit: /* C99 6.9 */ ; external_declaration: /* C99 6.9 */ - asm_statement - | function_definition { + function_definition { global_clean_up_decl(false); clear_warning_flags(); } @@ -1879,6 +1878,16 @@ external_declaration: /* C99 6.9 */ global_clean_up_decl(false); clear_warning_flags(); } + | asm_statement /* GCC extension */ + | T_SEMI { /* GCC extension */ + if (sflag) { + /* empty declaration */ + error(0); + } else if (!tflag) { + /* empty declaration */ + warning(0); + } + } ; /* @@ -1891,16 +1900,7 @@ external_declaration: /* C99 6.9 */ * See 'declaration' for all other declarations. */ top_level_declaration: /* C99 6.9 calls this 'declaration' */ - T_SEMI { - if (sflag) { - /* empty declaration */ - error(0); - } else if (!tflag) { - /* empty declaration */ - warning(0); - } - } - | begin_type end_type notype_init_declarators T_SEMI { + begin_type end_type notype_init_declarators T_SEMI { if (sflag) { /* old style declaration; add 'int' */ error(1);
CVS commit: src/usr.bin/ldd
Module Name:src Committed By: martin Date: Fri Jul 23 04:20:05 UTC 2021 Modified Files: src/usr.bin/ldd: ldd.c Log Message: gcc hates strncpy() To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/ldd/ldd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ldd/ldd.c diff -u src/usr.bin/ldd/ldd.c:1.24 src/usr.bin/ldd/ldd.c:1.25 --- src/usr.bin/ldd/ldd.c:1.24 Thu Jul 22 17:39:52 2021 +++ src/usr.bin/ldd/ldd.c Fri Jul 23 04:20:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ldd.c,v 1.24 2021/07/22 17:39:52 christos Exp $ */ +/* $NetBSD: ldd.c,v 1.25 2021/07/23 04:20:05 martin Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ldd.c,v 1.24 2021/07/22 17:39:52 christos Exp $"); +__RCSID("$NetBSD: ldd.c,v 1.25 2021/07/23 04:20:05 martin Exp $"); #endif /* not lint */ #include @@ -161,10 +161,13 @@ main(int argc, char **argv) for (; argc != 0; argc--, argv++) { int fd; - if (**argv != '/') - snprintf(path, sizeof(path), "%s/%s", cwd, *argv); - else + if (**argv != '/') { + strcpy(path, cwd); + strlcat(path, "/", sizeof(path)); + strlcat(path, *argv, sizeof(path)); + } else { strlcpy(path, *argv, sizeof(path)); + } fd = open(*argv, O_RDONLY); if (fd == -1) { exit_status = EXIT_FAILURE;
CVS commit: src/usr.bin/ldd
Module Name:src Committed By: christos Date: Thu Jul 22 17:39:53 UTC 2021 Modified Files: src/usr.bin/ldd: ldd.c ldd.h ldd_elfxx.c Log Message: rtld expects an absolute path in execname provided via AUXV in order to handle $ORIGIN properly and checks for that. Since we are calling its guts directly, provide one. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/ldd/ldd.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/ldd/ldd.h src/usr.bin/ldd/ldd_elfxx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ldd/ldd.c diff -u src/usr.bin/ldd/ldd.c:1.23 src/usr.bin/ldd/ldd.c:1.24 --- src/usr.bin/ldd/ldd.c:1.23 Mon Dec 25 00:08:49 2017 +++ src/usr.bin/ldd/ldd.c Thu Jul 22 13:39:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ldd.c,v 1.23 2017/12/25 05:08:49 maya Exp $ */ +/* $NetBSD: ldd.c,v 1.24 2021/07/22 17:39:52 christos Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ldd.c,v 1.23 2017/12/25 05:08:49 maya Exp $"); +__RCSID("$NetBSD: ldd.c,v 1.24 2021/07/22 17:39:52 christos Exp $"); #endif /* not lint */ #include @@ -123,6 +123,7 @@ main(int argc, char **argv) { const char *fmt1 = NULL, *fmt2 = NULL; int c, exit_status = EXIT_SUCCESS; + char cwd[MAXPATHLEN], path[MAXPATHLEN]; #ifdef DEBUG debug = 1; @@ -154,22 +155,28 @@ main(int argc, char **argv) usage(); /*NOTREACHED*/ } + if (getcwd(cwd, sizeof(cwd)) == NULL) + err(EXIT_FAILURE, "Can't get working directory"); for (; argc != 0; argc--, argv++) { int fd; + if (**argv != '/') + snprintf(path, sizeof(path), "%s/%s", cwd, *argv); + else + strlcpy(path, *argv, sizeof(path)); fd = open(*argv, O_RDONLY); if (fd == -1) { exit_status = EXIT_FAILURE; warn("%s", *argv); continue; } - if (elf_ldd(fd, *argv, fmt1, fmt2) == -1 + if (elf_ldd(fd, *argv, path, fmt1, fmt2) == -1 /* Alpha never had 32 bit support. */ #if (defined(_LP64) && !defined(ELF64_ONLY)) || defined(MIPS_N32) - && elf32_ldd(fd, *argv, fmt1, fmt2) == -1 + && elf32_ldd(fd, *argv, path, fmt1, fmt2) == -1 #if defined(__mips__) && 0 /* XXX this is still hosed for some reason */ - && elf32_ldd_compat(fd, *argv, fmt1, fmt2) == -1 + && elf32_ldd_compat(fd, *argv, path, fmt1, fmt2) == -1 #endif #endif ) { Index: src/usr.bin/ldd/ldd.h diff -u src/usr.bin/ldd/ldd.h:1.7 src/usr.bin/ldd/ldd.h:1.8 --- src/usr.bin/ldd/ldd.h:1.7 Sat Jul 7 20:53:44 2012 +++ src/usr.bin/ldd/ldd.h Thu Jul 22 13:39:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ldd.h,v 1.7 2012/07/08 00:53:44 matt Exp $ */ +/* $NetBSD: ldd.h,v 1.8 2021/07/22 17:39:53 christos Exp $ */ /* * Copyright (c) 2008 Matthew R. Green @@ -28,14 +28,14 @@ * SUCH DAMAGE. */ -int elf32_ldd(int, char *, const char *, const char *); +int elf32_ldd(int, char *, char *, const char *, const char *); #ifdef _LP64 #define LDD_ELF64 #endif #ifdef LDD_ELF64 -int elf64_ldd(int, char *, const char *, const char *); +int elf64_ldd(int, char *, char *, const char *, const char *); #define elf_ldd elf64_ldd #elif defined(ELF32_COMPAT) #define elf_ldd elf32_compat_ldd Index: src/usr.bin/ldd/ldd_elfxx.c diff -u src/usr.bin/ldd/ldd_elfxx.c:1.7 src/usr.bin/ldd/ldd_elfxx.c:1.8 --- src/usr.bin/ldd/ldd_elfxx.c:1.7 Tue Jan 10 16:11:25 2017 +++ src/usr.bin/ldd/ldd_elfxx.c Thu Jul 22 13:39:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ldd_elfxx.c,v 1.7 2017/01/10 21:11:25 christos Exp $ */ +/* $NetBSD: ldd_elfxx.c,v 1.8 2021/07/22 17:39:53 christos Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ldd_elfxx.c,v 1.7 2017/01/10 21:11:25 christos Exp $"); +__RCSID("$NetBSD: ldd_elfxx.c,v 1.8 2021/07/22 17:39:53 christos Exp $"); #endif /* not lint */ #include @@ -93,7 +93,7 @@ static void fmtprint(const char *, Obj_E * returns 0 on success and -1 on failure. */ int -ELFNAME(ldd)(int fd, char *path, const char *fmt1, const char *fmt2) +ELFNAME(ldd)(int fd, char *prog, char *path, const char *fmt1, const char *fmt2) { struct stat st; @@ -132,7 +132,7 @@ ELFNAME(ldd)(int fd, char *path, const c (void) _rtld_load_needed_objects(_rtld_objmain, 0); if (fmt1 == NULL) - printf("%s:\n", _rtld_objmain->path); + printf("%s:\n", prog); main_local = path; main_progname = _rtld_objmain->path; print_needed(_rtld_objmain, fmt1, fmt2);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Wed Jul 21 21:24:45 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: move assignments to $$ at the end of the action They are closely related to return statements. While here, add some more remarks from reviewing the grammar. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.333 -r1.334 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.333 src/usr.bin/xlint/lint1/cgram.y:1.334 --- src/usr.bin/xlint/lint1/cgram.y:1.333 Wed Jul 21 21:17:57 2021 +++ src/usr.bin/xlint/lint1/cgram.y Wed Jul 21 21:24:45 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.333 2021/07/21 21:17:57 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.334 2021/07/21 21:24:45 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.333 2021/07/21 21:17:57 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.334 2021/07/21 21:24:45 rillig Exp $"); #endif #include @@ -375,12 +375,12 @@ identifier_sym: /* helper for struct/u /* K ???, C90 ???, C99 6.4.2.1, C11 ??? */ identifier: T_NAME { + cgram_debug("name '%s'", $1->sb_name); $$ = $1; - cgram_debug("name '%s'", $$->sb_name); } | T_TYPENAME { + cgram_debug("typename '%s'", $1->sb_name); $$ = $1; - cgram_debug("typename '%s'", $$->sb_name); } ; @@ -543,9 +543,9 @@ gcc_statement_expr_item: /* XXX: do that only on the last name */ if ($1->tn_op == NAME) $1->tn_sym->s_used = true; - $$ = $1; expr($1, false, false, false, false); seen_fallthrough = false; + $$ = $1; } } ; @@ -615,6 +615,7 @@ unary_expression: } /* K ---, C90 ---, C99 ---, C11 6.5.3 */ | T_ALIGNOF T_LPAREN type_name T_RPAREN { + /* TODO: c11ism */ $$ = build_alignof($3); } ; @@ -736,6 +737,7 @@ declaration: /* C99 6.7 */ } } | begin_type_declmods end_type notype_init_declarators T_SEMI + /* ^^ There is no check for the missing type-specifier. */ | begin_type_declaration_specifiers end_type T_SEMI { if (dcs->d_scl == TYPEDEF) { /* typedef declares no type name */ @@ -777,6 +779,7 @@ begin_type_specifier_qualifier_list: /* begin_type_typespec { add_type($1); } + /* TODO: shift/reduce conflict for type_attribute */ | type_attribute begin_type_specifier_qualifier_list | begin_type_qualifier_list type_specifier { add_type($2); @@ -834,6 +837,7 @@ type_attribute: /* See C11 6.7 declara } gcc_attribute_spec_list { attron = false; } T_RPAREN T_RPAREN + /* TODO: c11ism */ | T_ALIGNAS T_LPAREN align_as T_RPAREN | T_PACKED { addpacked(); @@ -949,6 +953,7 @@ struct_declaration_list: /* C99 6.7.2.1 struct_declaration: /* C99 6.7.2.1 */ begin_type_qualifier_list end_type { + /* ^^ There is no check for the missing type-specifier. */ /* too late, i know, but getsym() compensates it */ symtyp = FMEMBER; } notype_struct_declarators type_attribute_opt T_SEMI { @@ -1475,12 +1480,14 @@ parameter_type_list: /* XXX: C99 6.7.5 defines the same name, but it looks completely different. */ parameter_declaration: begin_type_declmods end_type { + /* ^^ There is no check for the missing type-specifier. */ $$ = declare_argument(abstract_name(), false); } | begin_type_declaration_specifiers end_type { $$ = declare_argument(abstract_name(), false); } | begin_type_declmods end_type notype_param_declarator { + /* ^^ There is no check for the missing type-specifier. */ $$ = declare_argument($3, false); } /* @@ -1494,6 +1501,7 @@ parameter_declaration: $$ = declare_argument($3, false); } | begin_type_declmods end_type abstract_declarator { + /* ^^ There is no check for the missing type-specifier. */ $$ = declare_argument($3, false); } | begin_type_declaration_specifiers end_type abstract_declarator { @@ -1509,6 +1517,7 @@ initializer: /* C99 6.7.8 "Initializat /* XXX: Empty braces are not covered by C99 6.7.8. */ } | init_lbrace initializer_list comma_opt init_rbrace + /* XXX: What is this error handling for? */ | error ; @@ -1940,9 +1949,11 @@ function_definition: /* C99 6.9.1 */ func_declarator: begin_type end_type notype_declarator { + /* ^^ There is no check for the missing type-specifier. */ $$ = $3; } | begin_type_declmods end_type notype_declarator { + /* ^^ There is no check for the missing type-specifier. */ $$ = $3; } | begin_type_declaration_specifiers end_type type_declarator {
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Wed Jul 21 21:11:19 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: remove unnecessary assertion for type qualifier If there is any new type qualifier that lint should support (such as _Atomic from C11), the obvious place is to look in the grammar rule type_qualifier, so there is no need to have an assertion. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.331 -r1.332 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.331 src/usr.bin/xlint/lint1/cgram.y:1.332 --- src/usr.bin/xlint/lint1/cgram.y:1.331 Wed Jul 21 21:04:00 2021 +++ src/usr.bin/xlint/lint1/cgram.y Wed Jul 21 21:11:19 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.331 2021/07/21 21:04:00 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.332 2021/07/21 21:11:19 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.331 2021/07/21 21:04:00 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.332 2021/07/21 21:11:19 rillig Exp $"); #endif #include @@ -1109,13 +1109,10 @@ enumerator: /* C99 6.7.2.2 */ type_qualifier: /* C99 6.7.3 */ T_QUAL { $$ = xcalloc(1, sizeof(*$$)); - if ($1 == CONST) { + if ($1 == CONST) $$->p_const = true; - } else if ($1 == VOLATILE) { + if ($1 == VOLATILE) $$->p_volatile = true; - } else { - lint_assert($1 == RESTRICT || $1 == THREAD); - } } ;
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jul 20 19:44:36 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y externs1.h init.c tree.c Log Message: lint: use consistent naming scheme for functions that build nodes No functional change. To generate a diff of this commit: cvs rdiff -u -r1.329 -r1.330 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.119 -r1.120 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.317 -r1.318 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.329 src/usr.bin/xlint/lint1/cgram.y:1.330 --- src/usr.bin/xlint/lint1/cgram.y:1.329 Tue Jul 20 19:35:53 2021 +++ src/usr.bin/xlint/lint1/cgram.y Tue Jul 20 19:44:36 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.330 2021/07/20 19:44:36 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.330 2021/07/20 19:44:36 rillig Exp $"); #endif #include @@ -412,13 +412,13 @@ primary_expression: /* XXX really necessary? */ if (yychar < 0) yychar = yylex(); - $$ = new_name_node(getsym($1), yychar); + $$ = build_name(getsym($1), yychar); } | T_CON { - $$ = expr_new_constant(gettyp($1->v_tspec), $1); + $$ = build_constant(gettyp($1->v_tspec), $1); } | string { - $$ = new_string_node($1); + $$ = build_string($1); } | T_LPAREN expression T_RPAREN { if ($2 != NULL) @@ -473,10 +473,10 @@ postfix_expression: $$ = build_unary(INDIR, build_binary($1, PLUS, $3)); } | postfix_expression T_LPAREN T_RPAREN { - $$ = new_function_call_node($1, NULL); + $$ = build_function_call($1, NULL); } | postfix_expression T_LPAREN argument_expression_list T_RPAREN { - $$ = new_function_call_node($1, $3); + $$ = build_function_call($1, $3); } | postfix_expression point_or_arrow T_NAME { $$ = build_member_access($1, $2, $3); @@ -492,7 +492,7 @@ postfix_expression: if (!Sflag) /* compound literals are a C9X/GCC extension */ gnuism(319); - $$ = new_name_node(*current_initsym(), 0); + $$ = build_name(*current_initsym(), 0); end_initialization(); } | T_LPAREN compound_statement_lbrace gcc_statement_expr_list { @@ -504,7 +504,7 @@ postfix_expression: /* ({ }) is a GCC extension */ gnuism(320); } compound_statement_rbrace T_RPAREN { - $$ = new_name_node(*current_initsym(), 0); + $$ = build_name(*current_initsym(), 0); end_initialization(); } ; @@ -564,10 +564,10 @@ point_or_arrow: /* helper for 'postfix /* K 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */ argument_expression_list: assignment_expression { - $$ = new_function_argument_node(NULL, $1); + $$ = build_function_argument(NULL, $1); } | argument_expression_list T_COMMA assignment_expression { - $$ = new_function_argument_node($1, $3); + $$ = build_function_argument($1, $3); } ; Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.119 src/usr.bin/xlint/lint1/externs1.h:1.120 --- src/usr.bin/xlint/lint1/externs1.h:1.119 Tue Jul 20 19:35:53 2021 +++ src/usr.bin/xlint/lint1/externs1.h Tue Jul 20 19:44:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.119 2021/07/20 19:35:53 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.120 2021/07/20 19:44:36 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -204,9 +204,9 @@ extern int to_int_constant(tnode_t *, bo extern const tnode_t *before_conversion(const tnode_t *); extern type_t *derive_type(type_t *, tspec_t); extern type_t *expr_derive_type(type_t *, tspec_t); -extern tnode_t *expr_new_constant(type_t *, val_t *); -extern tnode_t *new_name_node(sym_t *, int); -extern tnode_t *new_string_node(strg_t *); +extern tnode_t *build_constant(type_t *, val_t *); +extern tnode_t *build_name(sym_t *, int); +extern tnode_t *build_string(strg_t *); extern sym_t *struct_or_union_member(tnode_t *, op_t, sym_t *); extern tnode_t *build_generic_selection(const tnode_t *, struct generic_association *); @@ -224,8 +224,8 @@ extern tnode_t *build_sizeof(const type_ extern tnode_t *build_offsetof(const type_t *, const sym_t *); extern tnode_t *build_alignof(const type_t *); extern tnode_t *cast(tnode_t *, type_t *); -extern tnode_t *new_function_argument_node(tnode_t *, tnode_t *); -extern tnode_t *new_function_call_node(tnode_t *, tnode_t *); +extern tnode_t *build_function_argument(tnode_t *, tnode_t *); +extern tnode_t *build_function_call(tnode_t *, tnode_t *); extern val_t *constant(tnode_t *, bool); extern void expr(tnode_t *, bool, bool, bool,
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Jul 20 19:35:53 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y externs1.h func.c init.c tree.c Log Message: lint: split 'build' into build_binary and build_unary No functional change. To generate a diff of this commit: cvs rdiff -u -r1.328 -r1.329 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.113 -r1.114 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.201 -r1.202 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.316 -r1.317 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.328 src/usr.bin/xlint/lint1/cgram.y:1.329 --- src/usr.bin/xlint/lint1/cgram.y:1.328 Thu Jul 15 20:05:49 2021 +++ src/usr.bin/xlint/lint1/cgram.y Tue Jul 20 19:35:53 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.328 2021/07/15 20:05:49 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.328 2021/07/15 20:05:49 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.329 2021/07/20 19:35:53 rillig Exp $"); #endif #include @@ -470,7 +470,7 @@ generic_association: postfix_expression: primary_expression | postfix_expression T_LBRACK expression T_RBRACK { - $$ = build(INDIR, build(PLUS, $1, $3), NULL); + $$ = build_unary(INDIR, build_binary($1, PLUS, $3)); } | postfix_expression T_LPAREN T_RPAREN { $$ = new_function_call_node($1, NULL); @@ -482,7 +482,7 @@ postfix_expression: $$ = build_member_access($1, $2, $3); } | postfix_expression T_INCDEC { - $$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL); + $$ = build_unary($2 == INC ? INCAFT : DECAFT, $1); } | T_LPAREN type_name T_RPAREN { /* C99 6.5.2.5 "Compound literals" */ sym_t *tmp = mktempsym($2); @@ -575,32 +575,32 @@ argument_expression_list: unary_expression: postfix_expression | T_INCDEC unary_expression { - $$ = build($1 == INC ? INCBEF : DECBEF, $2, NULL); + $$ = build_unary($1 == INC ? INCBEF : DECBEF, $2); } | T_AMPER cast_expression { - $$ = build(ADDR, $2, NULL); + $$ = build_unary(ADDR, $2); } | T_ASTERISK cast_expression { - $$ = build(INDIR, $2, NULL); + $$ = build_unary(INDIR, $2); } | T_ADDITIVE cast_expression { if (tflag && $1 == PLUS) { /* unary + is illegal in traditional C */ warning(100); } - $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL); + $$ = build_unary($1 == PLUS ? UPLUS : UMINUS, $2); } | T_COMPLEMENT cast_expression { - $$ = build(COMPL, $2, NULL); + $$ = build_unary(COMPL, $2); } | T_LOGNOT cast_expression { - $$ = build(NOT, $2, NULL); + $$ = build_unary(NOT, $2); } | T_REAL cast_expression { /* GCC c_parser_unary_expression */ - $$ = build(REAL, $2, NULL); + $$ = build_unary(REAL, $2); } | T_IMAG cast_expression { /* GCC c_parser_unary_expression */ - $$ = build(IMAG, $2, NULL); + $$ = build_unary(IMAG, $2); } | T_EXTENSION cast_expression { /* GCC c_parser_unary_expression */ $$ = $2; @@ -649,41 +649,41 @@ expression_opt: /* K ???, C90 ???, C99 6.5.5 to 6.5.15, C11 6.5.5 to 6.5.15 */ conditional_expression: conditional_expression T_ASTERISK conditional_expression { - $$ = build(MULT, $1, $3); + $$ = build_binary($1, MULT, $3); } | conditional_expression T_MULTIPLICATIVE conditional_expression { - $$ = build($2, $1, $3); + $$ = build_binary($1, $2, $3); } | conditional_expression T_ADDITIVE conditional_expression { - $$ = build($2, $1, $3); + $$ = build_binary($1, $2, $3); } | conditional_expression T_SHIFT conditional_expression { - $$ = build($2, $1, $3); + $$ = build_binary($1, $2, $3); } | conditional_expression T_RELATIONAL conditional_expression { - $$ = build($2, $1, $3); + $$ = build_binary($1, $2, $3); } | conditional_expression T_EQUALITY conditional_expression { - $$ = build($2, $1, $3); + $$ = build_binary($1, $2, $3); } | conditional_expression T_AMPER conditional_expression { - $$ = build(BITAND, $1, $3); + $$ = build_binary($1, BITAND, $3); } | conditional_expression T_BITXOR conditional_expression { - $$ = build(BITXOR, $1, $3); + $$ = build_binary($1, BITXOR, $3); } | conditional_expression T_BITOR conditional_expression { - $$ = build(BITOR, $1, $3); + $$ = build_binary($1, BITOR, $3); } | conditional_expression T_LOGAND conditional_expression { - $$ = build(LOGAND, $1, $3); + $$ = build_binary($1, LOGAND, $3); } | conditional_expression T_LOGOR conditional_expression { - $$ = build(LOGOR, $1, $3); + $$ = build_binary($1, LOGOR, $3); } | conditional_expression T_QUEST
CVS commit: src/usr.bin/xlint/arch/aarch64
Module Name:src Committed By: rillig Date: Tue Jul 20 18:43:06 UTC 2021 Modified Files: src/usr.bin/xlint/arch/aarch64: targparam.h Log Message: lint: make char unsigned on aarch64 This fixes tests msg_074 and msg_076, which previously warned for '\xff': conversion of 'int' to 'char' is out of range [119] The commit from 2014-08-10 that first defined char as signed had the remark "Enough for a distribution build". At that time, there was no unit test for lint1 that would have detected the signedness of char. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/xlint/arch/aarch64/targparam.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/arch/aarch64/targparam.h diff -u src/usr.bin/xlint/arch/aarch64/targparam.h:1.5 src/usr.bin/xlint/arch/aarch64/targparam.h:1.6 --- src/usr.bin/xlint/arch/aarch64/targparam.h:1.5 Sun Jun 27 08:43:46 2021 +++ src/usr.bin/xlint/arch/aarch64/targparam.h Tue Jul 20 18:43:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: targparam.h,v 1.5 2021/06/27 08:43:46 rillig Exp $ */ +/* $NetBSD: targparam.h,v 1.6 2021/07/20 18:43:06 rillig Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ /* * Machine-dependent target parameters for lint1. */ -#include "schar.h" +#include "uchar.h" #include "lp64.h" /*
CVS commit: src/usr.bin/aiomixer
Module Name:src Committed By: nia Date: Sun Jul 18 11:45:31 UTC 2021 Modified Files: src/usr.bin/aiomixer: main.c Log Message: aiomixer: Honor terminal colors. Looks better in cool-retro-term. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/aiomixer/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/aiomixer/main.c diff -u src/usr.bin/aiomixer/main.c:1.3 src/usr.bin/aiomixer/main.c:1.4 --- src/usr.bin/aiomixer/main.c:1.3 Thu Jul 15 06:57:10 2021 +++ src/usr.bin/aiomixer/main.c Sun Jul 18 11:45:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 2021/07/15 06:57:10 nia Exp $ */ +/* $NetBSD: main.c,v 1.4 2021/07/18 11:45:31 nia Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. * All rights reserved. @@ -537,6 +537,7 @@ main(int argc, char **argv) if (has_colors()) { start_color(); + use_default_colors(); init_pair(COLOR_CONTROL_SELECTED, COLOR_BLUE, COLOR_BLACK); init_pair(COLOR_LEVELS, COLOR_GREEN, COLOR_BLACK); init_pair(COLOR_SET_SELECTED, COLOR_BLACK, COLOR_GREEN);
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Thu Jul 15 23:54:22 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: reduce verboseness of merge_signedness No functional change. To generate a diff of this commit: cvs rdiff -u -r1.206 -r1.207 src/usr.bin/xlint/lint1/decl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.206 src/usr.bin/xlint/lint1/decl.c:1.207 --- src/usr.bin/xlint/lint1/decl.c:1.206 Thu Jul 15 23:47:00 2021 +++ src/usr.bin/xlint/lint1/decl.c Thu Jul 15 23:54:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.206 2021/07/15 23:47:00 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.207 2021/07/15 23:54:22 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.206 2021/07/15 23:47:00 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.207 2021/07/15 23:54:22 rillig Exp $"); #endif #include @@ -386,20 +386,16 @@ static tspec_t merge_signedness(tspec_t t, tspec_t s) { - if (s != SIGNED && s != UNSIGN) + if (s == SIGNED) + return t == CHAR ? SCHAR : t; + if (s != UNSIGN) return t; - - if (t == CHAR) - return s == SIGNED ? SCHAR : UCHAR; - if (t == SHORT) - return s == SIGNED ? SHORT : USHORT; - if (t == INT) - return s == SIGNED ? INT : UINT; - if (t == LONG) - return s == SIGNED ? LONG : ULONG; - if (t == QUAD) - return s == SIGNED ? QUAD : UQUAD; - return t; + return t == CHAR ? UCHAR + : t == SHORT ? USHORT + : t == INT ? UINT + : t == LONG ? ULONG + : t == QUAD ? UQUAD + : t; } /*
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Thu Jul 15 23:47:00 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: rename merge_type_specifiers to merge_signedness No functional change. To generate a diff of this commit: cvs rdiff -u -r1.205 -r1.206 src/usr.bin/xlint/lint1/decl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.205 src/usr.bin/xlint/lint1/decl.c:1.206 --- src/usr.bin/xlint/lint1/decl.c:1.205 Thu Jul 15 23:42:49 2021 +++ src/usr.bin/xlint/lint1/decl.c Thu Jul 15 23:47:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.205 2021/07/15 23:42:49 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.206 2021/07/15 23:47:00 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.205 2021/07/15 23:42:49 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.206 2021/07/15 23:47:00 rillig Exp $"); #endif #include @@ -64,7 +64,6 @@ dinfo_t *dcs; static type_t *tdeferr(type_t *, tspec_t); static void settdsym(type_t *, sym_t *); -static tspec_t merge_type_specifiers(tspec_t, tspec_t); static void align(int, int); static sym_t *newtag(sym_t *, scl_t, bool, bool); static bool eqargs(const type_t *, const type_t *, bool *); @@ -382,6 +381,27 @@ add_type(type_t *tp) } } +/* Merge the signedness into the abstract type. */ +static tspec_t +merge_signedness(tspec_t t, tspec_t s) +{ + + if (s != SIGNED && s != UNSIGN) + return t; + + if (t == CHAR) + return s == SIGNED ? SCHAR : UCHAR; + if (t == SHORT) + return s == SIGNED ? SHORT : USHORT; + if (t == INT) + return s == SIGNED ? INT : UINT; + if (t == LONG) + return s == SIGNED ? LONG : ULONG; + if (t == QUAD) + return s == SIGNED ? QUAD : UQUAD; + return t; +} + /* * called if a list of declaration specifiers contains a typedef name * and other specifiers (except struct, union, enum, typedef name) @@ -401,7 +421,7 @@ tdeferr(type_t *td, tspec_t t) if (!tflag) /* modifying typedef with '%s'; only ... */ warning(5, ttab[t].tt_name); - td = dup_type(gettyp(merge_type_specifiers(t2, t))); + td = dup_type(gettyp(merge_signedness(t2, t))); td->t_typedef = true; return td; } @@ -814,7 +834,7 @@ dcs_merge_declaration_specifiers(void) } if (l != NOTSPEC) t = l; - dcs->d_type = gettyp(merge_type_specifiers(t, s)); + dcs->d_type = gettyp(merge_signedness(t, s)); } /* @@ -859,29 +879,6 @@ end_type(void) } /* - * Merge type specifiers (char, ..., long long, signed, unsigned). - */ -static tspec_t -merge_type_specifiers(tspec_t t, tspec_t s) -{ - - if (s != SIGNED && s != UNSIGN) - return t; - - if (t == CHAR) - return s == SIGNED ? SCHAR : UCHAR; - if (t == SHORT) - return s == SIGNED ? SHORT : USHORT; - if (t == INT) - return s == SIGNED ? INT : UINT; - if (t == LONG) - return s == SIGNED ? LONG : ULONG; - if (t == QUAD) - return s == SIGNED ? QUAD : UQUAD; - return t; -} - -/* * Return the length of a type in bits. * * Printing a message if the outermost dimension of an array is 0 must