make(1): fix lint warningsdiff -r1.192 -r1.193 src/usr.bin/make/arch.c
(rillig)
--- src/usr.bin/make/arch.c 2020/12/30 10:03:16 1.192
+++ src/usr.bin/make/arch.c 2021/01/09 16:06:09 1.193
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: arch.c,v 1.192 2020/12/30 10:03:16 rillig Exp $ */ | 1 | /* $NetBSD: arch.c,v 1.193 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | 4 | * Copyright (c) 1988, 1989, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -116,27 +116,27 @@ | @@ -116,27 +116,27 @@ | |||
116 | #include <sys/types.h> | 116 | #include <sys/types.h> | |
117 | #include <sys/stat.h> | 117 | #include <sys/stat.h> | |
118 | #include <sys/time.h> | 118 | #include <sys/time.h> | |
119 | #include <sys/param.h> | 119 | #include <sys/param.h> | |
120 | 120 | |||
121 | #include <ar.h> | 121 | #include <ar.h> | |
122 | #include <utime.h> | 122 | #include <utime.h> | |
123 | 123 | |||
124 | #include "make.h" | 124 | #include "make.h" | |
125 | #include "dir.h" | 125 | #include "dir.h" | |
126 | #include "config.h" | 126 | #include "config.h" | |
127 | 127 | |||
128 | /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ | 128 | /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ | |
129 | MAKE_RCSID("$NetBSD: arch.c,v 1.192 2020/12/30 10:03:16 rillig Exp $"); | 129 | MAKE_RCSID("$NetBSD: arch.c,v 1.193 2021/01/09 16:06:09 rillig Exp $"); | |
130 | 130 | |||
131 | typedef struct List ArchList; | 131 | typedef struct List ArchList; | |
132 | typedef struct ListNode ArchListNode; | 132 | typedef struct ListNode ArchListNode; | |
133 | 133 | |||
134 | static ArchList archives; /* The archives we've already examined */ | 134 | static ArchList archives; /* The archives we've already examined */ | |
135 | 135 | |||
136 | typedef struct Arch { | 136 | typedef struct Arch { | |
137 | char *name; /* Name of archive */ | 137 | char *name; /* Name of archive */ | |
138 | HashTable members; /* All the members of the archive described | 138 | HashTable members; /* All the members of the archive described | |
139 | * by <name, struct ar_hdr *> key/value pairs */ | 139 | * by <name, struct ar_hdr *> key/value pairs */ | |
140 | char *fnametab; /* Extended name table strings */ | 140 | char *fnametab; /* Extended name table strings */ | |
141 | size_t fnamesize; /* Size of the string table */ | 141 | size_t fnamesize; /* Size of the string table */ | |
142 | } Arch; | 142 | } Arch; | |
@@ -861,26 +861,27 @@ Arch_Touch(GNode *gn) | @@ -861,26 +861,27 @@ Arch_Touch(GNode *gn) | |||
861 | 861 | |||
862 | snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now); | 862 | snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now); | |
863 | (void)fwrite(&arh, sizeof arh, 1, f); | 863 | (void)fwrite(&arh, sizeof arh, 1, f); | |
864 | fclose(f); /* TODO: handle errors */ | 864 | fclose(f); /* TODO: handle errors */ | |
865 | } | 865 | } | |
866 | 866 | |||
867 | /* | 867 | /* | |
868 | * Given a node which represents a library, touch the thing, making sure that | 868 | * Given a node which represents a library, touch the thing, making sure that | |
869 | * the table of contents is also touched. | 869 | * the table of contents is also touched. | |
870 | * | 870 | * | |
871 | * Both the modification time of the library and of the RANLIBMAG member are | 871 | * Both the modification time of the library and of the RANLIBMAG member are | |
872 | * set to 'now'. | 872 | * set to 'now'. | |
873 | */ | 873 | */ | |
874 | /*ARGSUSED*/ | |||
874 | void | 875 | void | |
875 | Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED) | 876 | Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED) | |
876 | { | 877 | { | |
877 | #ifdef RANLIBMAG | 878 | #ifdef RANLIBMAG | |
878 | FILE *f; | 879 | FILE *f; | |
879 | struct ar_hdr arh; /* Header describing table of contents */ | 880 | struct ar_hdr arh; /* Header describing table of contents */ | |
880 | struct utimbuf times; | 881 | struct utimbuf times; | |
881 | 882 | |||
882 | f = ArchFindMember(gn->path, RANLIBMAG, &arh, "r+"); | 883 | f = ArchFindMember(gn->path, RANLIBMAG, &arh, "r+"); | |
883 | if (f == NULL) | 884 | if (f == NULL) | |
884 | return; | 885 | return; | |
885 | 886 | |||
886 | snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now); | 887 | snprintf(arh.ar_date, sizeof arh.ar_date, "%-ld", (unsigned long)now); |
--- src/usr.bin/make/cond.c 2020/12/30 10:03:16 1.233
+++ src/usr.bin/make/cond.c 2021/01/09 16:06:09 1.234
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cond.c,v 1.233 2020/12/30 10:03:16 rillig Exp $ */ | 1 | /* $NetBSD: cond.c,v 1.234 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | 4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -85,27 +85,27 @@ | @@ -85,27 +85,27 @@ | |||
85 | * Cond_restore_depth | 85 | * Cond_restore_depth | |
86 | * Save and restore the nesting of the conditions, at | 86 | * Save and restore the nesting of the conditions, at | |
87 | * the start and end of including another makefile, to | 87 | * the start and end of including another makefile, to | |
88 | * ensure that in each makefile the conditional | 88 | * ensure that in each makefile the conditional | |
89 | * directives are well-balanced. | 89 | * directives are well-balanced. | |
90 | */ | 90 | */ | |
91 | 91 | |||
92 | #include <errno.h> | 92 | #include <errno.h> | |
93 | 93 | |||
94 | #include "make.h" | 94 | #include "make.h" | |
95 | #include "dir.h" | 95 | #include "dir.h" | |
96 | 96 | |||
97 | /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ | 97 | /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ | |
98 | MAKE_RCSID("$NetBSD: cond.c,v 1.233 2020/12/30 10:03:16 rillig Exp $"); | 98 | MAKE_RCSID("$NetBSD: cond.c,v 1.234 2021/01/09 16:06:09 rillig Exp $"); | |
99 | 99 | |||
100 | /* | 100 | /* | |
101 | * The parsing of conditional expressions is based on this grammar: | 101 | * The parsing of conditional expressions is based on this grammar: | |
102 | * E -> F || E | 102 | * E -> F || E | |
103 | * E -> F | 103 | * E -> F | |
104 | * F -> T && F | 104 | * F -> T && F | |
105 | * F -> T | 105 | * F -> T | |
106 | * T -> defined(variable) | 106 | * T -> defined(variable) | |
107 | * T -> make(target) | 107 | * T -> make(target) | |
108 | * T -> exists(file) | 108 | * T -> exists(file) | |
109 | * T -> empty(varspec) | 109 | * T -> empty(varspec) | |
110 | * T -> target(name) | 110 | * T -> target(name) | |
111 | * T -> commands(name) | 111 | * T -> commands(name) | |
@@ -276,74 +276,79 @@ ParseFuncArg(const char **pp, Boolean do | @@ -276,74 +276,79 @@ ParseFuncArg(const char **pp, Boolean do | |||
276 | if (func != NULL && *p++ != ')') { | 276 | if (func != NULL && *p++ != ')') { | |
277 | Parse_Error(PARSE_WARNING, | 277 | Parse_Error(PARSE_WARNING, | |
278 | "Missing closing parenthesis for %s()", | 278 | "Missing closing parenthesis for %s()", | |
279 | func); | 279 | func); | |
280 | /* The PARSE_FATAL follows in CondEvalExpression. */ | 280 | /* The PARSE_FATAL follows in CondEvalExpression. */ | |
281 | return 0; | 281 | return 0; | |
282 | } | 282 | } | |
283 | 283 | |||
284 | *pp = p; | 284 | *pp = p; | |
285 | return argLen; | 285 | return argLen; | |
286 | } | 286 | } | |
287 | 287 | |||
288 | /* Test whether the given variable is defined. */ | 288 | /* Test whether the given variable is defined. */ | |
289 | /*ARGSUSED*/ | |||
289 | static Boolean | 290 | static Boolean | |
290 | FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | 291 | FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | |
291 | { | 292 | { | |
292 | FStr value = Var_Value(arg, VAR_CMDLINE); | 293 | FStr value = Var_Value(arg, VAR_CMDLINE); | |
293 | Boolean result = value.str != NULL; | 294 | Boolean result = value.str != NULL; | |
294 | FStr_Done(&value); | 295 | FStr_Done(&value); | |
295 | return result; | 296 | return result; | |
296 | } | 297 | } | |
297 | 298 | |||
298 | /* See if the given target is being made. */ | 299 | /* See if the given target is being made. */ | |
300 | /*ARGSUSED*/ | |||
299 | static Boolean | 301 | static Boolean | |
300 | FuncMake(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | 302 | FuncMake(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | |
301 | { | 303 | { | |
302 | StringListNode *ln; | 304 | StringListNode *ln; | |
303 | 305 | |||
304 | for (ln = opts.create.first; ln != NULL; ln = ln->next) | 306 | for (ln = opts.create.first; ln != NULL; ln = ln->next) | |
305 | if (Str_Match(ln->datum, arg)) | 307 | if (Str_Match(ln->datum, arg)) | |
306 | return TRUE; | 308 | return TRUE; | |
307 | return FALSE; | 309 | return FALSE; | |
308 | } | 310 | } | |
309 | 311 | |||
310 | /* See if the given file exists. */ | 312 | /* See if the given file exists. */ | |
313 | /*ARGSUSED*/ | |||
311 | static Boolean | 314 | static Boolean | |
312 | FuncExists(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | 315 | FuncExists(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | |
313 | { | 316 | { | |
314 | Boolean result; | 317 | Boolean result; | |
315 | char *path; | 318 | char *path; | |
316 | 319 | |||
317 | path = Dir_FindFile(arg, &dirSearchPath); | 320 | path = Dir_FindFile(arg, &dirSearchPath); | |
318 | DEBUG2(COND, "exists(%s) result is \"%s\"\n", | 321 | DEBUG2(COND, "exists(%s) result is \"%s\"\n", | |
319 | arg, path != NULL ? path : ""); | 322 | arg, path != NULL ? path : ""); | |
320 | result = path != NULL; | 323 | result = path != NULL; | |
321 | free(path); | 324 | free(path); | |
322 | return result; | 325 | return result; | |
323 | } | 326 | } | |
324 | 327 | |||
325 | /* See if the given node exists and is an actual target. */ | 328 | /* See if the given node exists and is an actual target. */ | |
329 | /*ARGSUSED*/ | |||
326 | static Boolean | 330 | static Boolean | |
327 | FuncTarget(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | 331 | FuncTarget(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | |
328 | { | 332 | { | |
329 | GNode *gn = Targ_FindNode(arg); | 333 | GNode *gn = Targ_FindNode(arg); | |
330 | return gn != NULL && GNode_IsTarget(gn); | 334 | return gn != NULL && GNode_IsTarget(gn); | |
331 | } | 335 | } | |
332 | 336 | |||
333 | /* | 337 | /* | |
334 | * See if the given node exists and is an actual target with commands | 338 | * See if the given node exists and is an actual target with commands | |
335 | * associated with it. | 339 | * associated with it. | |
336 | */ | 340 | */ | |
341 | /*ARGSUSED*/ | |||
337 | static Boolean | 342 | static Boolean | |
338 | FuncCommands(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | 343 | FuncCommands(size_t argLen MAKE_ATTR_UNUSED, const char *arg) | |
339 | { | 344 | { | |
340 | GNode *gn = Targ_FindNode(arg); | 345 | GNode *gn = Targ_FindNode(arg); | |
341 | return gn != NULL && GNode_IsTarget(gn) && !Lst_IsEmpty(&gn->commands); | 346 | return gn != NULL && GNode_IsTarget(gn) && !Lst_IsEmpty(&gn->commands); | |
342 | } | 347 | } | |
343 | 348 | |||
344 | /* | 349 | /* | |
345 | * Convert the given number into a double. | 350 | * Convert the given number into a double. | |
346 | * We try a base 10 or 16 integer conversion first, if that fails | 351 | * We try a base 10 or 16 integer conversion first, if that fails | |
347 | * then we try a floating point conversion instead. | 352 | * then we try a floating point conversion instead. | |
348 | * | 353 | * | |
349 | * Results: | 354 | * Results: | |
@@ -687,26 +692,27 @@ CondParser_Comparison(CondParser *par, B | @@ -687,26 +692,27 @@ CondParser_Comparison(CondParser *par, B | |||
687 | t = EvalCompare(lhs.str, lhsQuoted, op, rhs.str, rhsQuoted); | 692 | t = EvalCompare(lhs.str, lhsQuoted, op, rhs.str, rhsQuoted); | |
688 | 693 | |||
689 | done_rhs: | 694 | done_rhs: | |
690 | FStr_Done(&rhs); | 695 | FStr_Done(&rhs); | |
691 | done_lhs: | 696 | done_lhs: | |
692 | FStr_Done(&lhs); | 697 | FStr_Done(&lhs); | |
693 | return t; | 698 | return t; | |
694 | } | 699 | } | |
695 | 700 | |||
696 | /* | 701 | /* | |
697 | * The argument to empty() is a variable name, optionally followed by | 702 | * The argument to empty() is a variable name, optionally followed by | |
698 | * variable modifiers. | 703 | * variable modifiers. | |
699 | */ | 704 | */ | |
705 | /*ARGSUSED*/ | |||
700 | static size_t | 706 | static size_t | |
701 | ParseEmptyArg(const char **pp, Boolean doEval, | 707 | ParseEmptyArg(const char **pp, Boolean doEval, | |
702 | const char *func MAKE_ATTR_UNUSED, char **out_arg) | 708 | const char *func MAKE_ATTR_UNUSED, char **out_arg) | |
703 | { | 709 | { | |
704 | FStr val; | 710 | FStr val; | |
705 | size_t magic_res; | 711 | size_t magic_res; | |
706 | 712 | |||
707 | /* We do all the work here and return the result as the length */ | 713 | /* We do all the work here and return the result as the length */ | |
708 | *out_arg = NULL; | 714 | *out_arg = NULL; | |
709 | 715 | |||
710 | (*pp)--; /* Make (*pp)[1] point to the '('. */ | 716 | (*pp)--; /* Make (*pp)[1] point to the '('. */ | |
711 | (void)Var_Parse(pp, VAR_CMDLINE, doEval ? VARE_WANTRES : VARE_NONE, | 717 | (void)Var_Parse(pp, VAR_CMDLINE, doEval ? VARE_WANTRES : VARE_NONE, | |
712 | &val); | 718 | &val); | |
@@ -723,26 +729,27 @@ ParseEmptyArg(const char **pp, Boolean d | @@ -723,26 +729,27 @@ ParseEmptyArg(const char **pp, Boolean d | |||
723 | * 4/15/92, christos | 729 | * 4/15/92, christos | |
724 | */ | 730 | */ | |
725 | cpp_skip_whitespace(&val.str); | 731 | cpp_skip_whitespace(&val.str); | |
726 | 732 | |||
727 | /* | 733 | /* | |
728 | * For consistency with the other functions we can't generate the | 734 | * For consistency with the other functions we can't generate the | |
729 | * true/false here. | 735 | * true/false here. | |
730 | */ | 736 | */ | |
731 | magic_res = val.str[0] != '\0' ? 2 : 1; | 737 | magic_res = val.str[0] != '\0' ? 2 : 1; | |
732 | FStr_Done(&val); | 738 | FStr_Done(&val); | |
733 | return magic_res; | 739 | return magic_res; | |
734 | } | 740 | } | |
735 | 741 | |||
742 | /*ARGSUSED*/ | |||
736 | static Boolean | 743 | static Boolean | |
737 | FuncEmpty(size_t arglen, const char *arg MAKE_ATTR_UNUSED) | 744 | FuncEmpty(size_t arglen, const char *arg MAKE_ATTR_UNUSED) | |
738 | { | 745 | { | |
739 | /* Magic values ahead, see ParseEmptyArg. */ | 746 | /* Magic values ahead, see ParseEmptyArg. */ | |
740 | return arglen == 1; | 747 | return arglen == 1; | |
741 | } | 748 | } | |
742 | 749 | |||
743 | static Boolean | 750 | static Boolean | |
744 | CondParser_Func(CondParser *par, Boolean doEval, Token *out_token) | 751 | CondParser_Func(CondParser *par, Boolean doEval, Token *out_token) | |
745 | { | 752 | { | |
746 | static const struct fn_def { | 753 | static const struct fn_def { | |
747 | const char *fn_name; | 754 | const char *fn_name; | |
748 | size_t fn_name_len; | 755 | size_t fn_name_len; |
--- src/usr.bin/make/Attic/enum.c 2020/12/30 10:03:16 1.13
+++ src/usr.bin/make/Attic/enum.c 2021/01/09 16:06:09 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: enum.c,v 1.13 2020/12/30 10:03:16 rillig Exp $ */ | 1 | /* $NetBSD: enum.c,v 1.14 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | Copyright (c) 2020 Roland Illig <rillig@NetBSD.org> | 4 | Copyright (c) 2020 Roland Illig <rillig@NetBSD.org> | |
5 | All rights reserved. | 5 | All rights reserved. | |
6 | 6 | |||
7 | Redistribution and use in source and binary forms, with or without | 7 | Redistribution and use in source and binary forms, with or without | |
8 | modification, are permitted provided that the following conditions | 8 | modification, are permitted provided that the following conditions | |
9 | are met: | 9 | are met: | |
10 | 10 | |||
11 | 1. Redistributions of source code must retain the above copyright | 11 | 1. Redistributions of source code must retain the above copyright | |
12 | notice, this list of conditions and the following disclaimer. | 12 | notice, this list of conditions and the following disclaimer. | |
13 | 2. Redistributions in binary form must reproduce the above copyright | 13 | 2. Redistributions in binary form must reproduce the above copyright | |
14 | notice, this list of conditions and the following disclaimer in the | 14 | notice, this list of conditions and the following disclaimer in the | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
20 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS | 20 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS | |
21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
27 | POSSIBILITY OF SUCH DAMAGE. | 27 | POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include "make.h" | 30 | #include "make.h" | |
31 | 31 | |||
32 | MAKE_RCSID("$NetBSD: enum.c,v 1.13 2020/12/30 10:03:16 rillig Exp $"); | 32 | MAKE_RCSID("$NetBSD: enum.c,v 1.14 2021/01/09 16:06:09 rillig Exp $"); | |
33 | 33 | |||
34 | /* | 34 | /* | |
35 | * Convert a bitset into a string representation, showing the names of the | 35 | * Convert a bitset into a string representation, showing the names of the | |
36 | * individual bits. | 36 | * individual bits. | |
37 | * | 37 | * | |
38 | * Optionally, shortcuts for groups of bits can be added. To have an effect, | 38 | * Optionally, shortcuts for groups of bits can be added. To have an effect, | |
39 | * they need to be listed before their individual bits. | 39 | * they need to be listed before their individual bits. | |
40 | */ | 40 | */ | |
41 | const char * | 41 | const char * | |
42 | Enum_FlagsToString(char *buf, size_t buf_size, | 42 | Enum_FlagsToString(char *buf, size_t buf_size, | |
43 | int value, const EnumToStringSpec *spec) | 43 | int value, const EnumToStringSpec *spec) | |
44 | { | 44 | { | |
45 | const char *buf_start = buf; | 45 | const char *buf_start = buf; | |
@@ -78,14 +78,15 @@ Enum_FlagsToString(char *buf, size_t buf | @@ -78,14 +78,15 @@ Enum_FlagsToString(char *buf, size_t buf | |||
78 | buf[0] = '\0'; | 78 | buf[0] = '\0'; | |
79 | return buf_start; | 79 | return buf_start; | |
80 | } | 80 | } | |
81 | 81 | |||
82 | /* Convert a fixed-value enum into a string representation. */ | 82 | /* Convert a fixed-value enum into a string representation. */ | |
83 | const char * | 83 | const char * | |
84 | Enum_ValueToString(int value, const EnumToStringSpec *spec) | 84 | Enum_ValueToString(int value, const EnumToStringSpec *spec) | |
85 | { | 85 | { | |
86 | for (; spec->es_name[0] != '\0'; spec++) { | 86 | for (; spec->es_name[0] != '\0'; spec++) { | |
87 | if (value == spec->es_value) | 87 | if (value == spec->es_value) | |
88 | return spec->es_name; | 88 | return spec->es_name; | |
89 | } | 89 | } | |
90 | abort(/* unknown enum value */); | 90 | abort(/* unknown enum value */); | |
91 | /*NOTREACHED*/ | |||
91 | } | 92 | } |
--- src/usr.bin/make/for.c 2020/12/31 14:10:04 1.132
+++ src/usr.bin/make/for.c 2021/01/09 16:06:09 1.133
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: for.c,v 1.132 2020/12/31 14:10:04 rillig Exp $ */ | 1 | /* $NetBSD: for.c,v 1.133 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1992, The Regents of the University of California. | 4 | * Copyright (c) 1992, The Regents of the University of California. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -48,27 +48,27 @@ | @@ -48,27 +48,27 @@ | |||
48 | * body is scanned for variable expressions, and those that match the variable | 48 | * body is scanned for variable expressions, and those that match the variable | |
49 | * names are replaced with expressions of the form ${:U...} or $(:U...). | 49 | * names are replaced with expressions of the form ${:U...} or $(:U...). | |
50 | * After that, the body is treated like a file from an .include directive. | 50 | * After that, the body is treated like a file from an .include directive. | |
51 | * | 51 | * | |
52 | * Interface: | 52 | * Interface: | |
53 | * For_Eval Evaluate the loop in the passed line. | 53 | * For_Eval Evaluate the loop in the passed line. | |
54 | * | 54 | * | |
55 | * For_Run Run accumulated loop | 55 | * For_Run Run accumulated loop | |
56 | */ | 56 | */ | |
57 | 57 | |||
58 | #include "make.h" | 58 | #include "make.h" | |
59 | 59 | |||
60 | /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ | 60 | /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ | |
61 | MAKE_RCSID("$NetBSD: for.c,v 1.132 2020/12/31 14:10:04 rillig Exp $"); | 61 | MAKE_RCSID("$NetBSD: for.c,v 1.133 2021/01/09 16:06:09 rillig Exp $"); | |
62 | 62 | |||
63 | static int forLevel = 0; /* Nesting level */ | 63 | static int forLevel = 0; /* Nesting level */ | |
64 | 64 | |||
65 | /* One of the variables to the left of the "in" in a .for loop. */ | 65 | /* One of the variables to the left of the "in" in a .for loop. */ | |
66 | typedef struct ForVar { | 66 | typedef struct ForVar { | |
67 | char *name; | 67 | char *name; | |
68 | size_t nameLen; | 68 | size_t nameLen; | |
69 | } ForVar; | 69 | } ForVar; | |
70 | 70 | |||
71 | /* | 71 | /* | |
72 | * State of a for loop. | 72 | * State of a for loop. | |
73 | */ | 73 | */ | |
74 | typedef struct For { | 74 | typedef struct For { | |
@@ -468,27 +468,27 @@ ForSubstBody(For *f) | @@ -468,27 +468,27 @@ ForSubstBody(For *f) | |||
468 | static char * | 468 | static char * | |
469 | ForReadMore(void *v_arg, size_t *out_len) | 469 | ForReadMore(void *v_arg, size_t *out_len) | |
470 | { | 470 | { | |
471 | For *f = v_arg; | 471 | For *f = v_arg; | |
472 | 472 | |||
473 | if (f->sub_next == f->items.len) { | 473 | if (f->sub_next == f->items.len) { | |
474 | /* No more iterations */ | 474 | /* No more iterations */ | |
475 | For_Free(f); | 475 | For_Free(f); | |
476 | return NULL; | 476 | return NULL; | |
477 | } | 477 | } | |
478 | 478 | |||
479 | ForSubstBody(f); | 479 | ForSubstBody(f); | |
480 | DEBUG1(FOR, "For: loop body:\n%s", f->curBody.data); | 480 | DEBUG1(FOR, "For: loop body:\n%s", f->curBody.data); | |
481 | f->sub_next += f->vars.len; | 481 | f->sub_next += (unsigned int)f->vars.len; | |
482 | 482 | |||
483 | *out_len = f->curBody.len; | 483 | *out_len = f->curBody.len; | |
484 | return f->curBody.data; | 484 | return f->curBody.data; | |
485 | } | 485 | } | |
486 | 486 | |||
487 | /* Run the .for loop, imitating the actions of an include file. */ | 487 | /* Run the .for loop, imitating the actions of an include file. */ | |
488 | void | 488 | void | |
489 | For_Run(int lineno) | 489 | For_Run(int lineno) | |
490 | { | 490 | { | |
491 | For *f = accumFor; | 491 | For *f = accumFor; | |
492 | accumFor = NULL; | 492 | accumFor = NULL; | |
493 | 493 | |||
494 | if (f->items.len == 0) { | 494 | if (f->items.len == 0) { |
--- src/usr.bin/make/job.c 2021/01/08 21:46:50 1.394
+++ src/usr.bin/make/job.c 2021/01/09 16:06:09 1.395
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: job.c,v 1.394 2021/01/08 21:46:50 sjg Exp $ */ | 1 | /* $NetBSD: job.c,v 1.395 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | 4 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -133,27 +133,27 @@ | @@ -133,27 +133,27 @@ | |||
133 | #ifndef USE_SELECT | 133 | #ifndef USE_SELECT | |
134 | #include <poll.h> | 134 | #include <poll.h> | |
135 | #endif | 135 | #endif | |
136 | #include <signal.h> | 136 | #include <signal.h> | |
137 | #include <utime.h> | 137 | #include <utime.h> | |
138 | 138 | |||
139 | #include "make.h" | 139 | #include "make.h" | |
140 | #include "dir.h" | 140 | #include "dir.h" | |
141 | #include "job.h" | 141 | #include "job.h" | |
142 | #include "pathnames.h" | 142 | #include "pathnames.h" | |
143 | #include "trace.h" | 143 | #include "trace.h" | |
144 | 144 | |||
145 | /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ | 145 | /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ | |
146 | MAKE_RCSID("$NetBSD: job.c,v 1.394 2021/01/08 21:46:50 sjg Exp $"); | 146 | MAKE_RCSID("$NetBSD: job.c,v 1.395 2021/01/09 16:06:09 rillig Exp $"); | |
147 | 147 | |||
148 | /* | 148 | /* | |
149 | * A shell defines how the commands are run. All commands for a target are | 149 | * A shell defines how the commands are run. All commands for a target are | |
150 | * written into a single file, which is then given to the shell to execute | 150 | * written into a single file, which is then given to the shell to execute | |
151 | * the commands from it. The commands are written to the file using a few | 151 | * the commands from it. The commands are written to the file using a few | |
152 | * templates for echo control and error control. | 152 | * templates for echo control and error control. | |
153 | * | 153 | * | |
154 | * The name of the shell is the basename for the predefined shells, such as | 154 | * The name of the shell is the basename for the predefined shells, such as | |
155 | * "sh", "csh", "bash". For custom shells, it is the full pathname, and its | 155 | * "sh", "csh", "bash". For custom shells, it is the full pathname, and its | |
156 | * basename is used to select the type of shell; the longest match wins. | 156 | * basename is used to select the type of shell; the longest match wins. | |
157 | * So /usr/pkg/bin/bash has type sh, /usr/local/bin/tcsh has type csh. | 157 | * So /usr/pkg/bin/bash has type sh, /usr/local/bin/tcsh has type csh. | |
158 | * | 158 | * | |
159 | * The echoing of command lines is controlled using hasEchoCtl, echoOff, | 159 | * The echoing of command lines is controlled using hasEchoCtl, echoOff, | |
@@ -589,36 +589,38 @@ JobCondPassSig(int signo) | @@ -589,36 +589,38 @@ JobCondPassSig(int signo) | |||
589 | if (job->status != JOB_ST_RUNNING) | 589 | if (job->status != JOB_ST_RUNNING) | |
590 | continue; | 590 | continue; | |
591 | DEBUG2(JOB, "JobCondPassSig passing signal %d to child %d.\n", | 591 | DEBUG2(JOB, "JobCondPassSig passing signal %d to child %d.\n", | |
592 | signo, job->pid); | 592 | signo, job->pid); | |
593 | KILLPG(job->pid, signo); | 593 | KILLPG(job->pid, signo); | |
594 | } | 594 | } | |
595 | } | 595 | } | |
596 | 596 | |||
597 | /* | 597 | /* | |
598 | * SIGCHLD handler. | 598 | * SIGCHLD handler. | |
599 | * | 599 | * | |
600 | * Sends a token on the child exit pipe to wake us up from select()/poll(). | 600 | * Sends a token on the child exit pipe to wake us up from select()/poll(). | |
601 | */ | 601 | */ | |
602 | /*ARGSUSED*/ | |||
602 | static void | 603 | static void | |
603 | JobChildSig(int signo MAKE_ATTR_UNUSED) | 604 | JobChildSig(int signo MAKE_ATTR_UNUSED) | |
604 | { | 605 | { | |
605 | while (write(childExitJob.outPipe, CHILD_EXIT, 1) == -1 && | 606 | while (write(childExitJob.outPipe, CHILD_EXIT, 1) == -1 && | |
606 | errno == EAGAIN) | 607 | errno == EAGAIN) | |
607 | continue; | 608 | continue; | |
608 | } | 609 | } | |
609 | 610 | |||
610 | 611 | |||
611 | /* Resume all stopped jobs. */ | 612 | /* Resume all stopped jobs. */ | |
613 | /*ARGSUSED*/ | |||
612 | static void | 614 | static void | |
613 | JobContinueSig(int signo MAKE_ATTR_UNUSED) | 615 | JobContinueSig(int signo MAKE_ATTR_UNUSED) | |
614 | { | 616 | { | |
615 | /* | 617 | /* | |
616 | * Defer sending SIGCONT to our stopped children until we return | 618 | * Defer sending SIGCONT to our stopped children until we return | |
617 | * from the signal handler. | 619 | * from the signal handler. | |
618 | */ | 620 | */ | |
619 | while (write(childExitJob.outPipe, DO_JOB_RESUME, 1) == -1 && | 621 | while (write(childExitJob.outPipe, DO_JOB_RESUME, 1) == -1 && | |
620 | errno == EAGAIN) | 622 | errno == EAGAIN) | |
621 | continue; | 623 | continue; | |
622 | } | 624 | } | |
623 | 625 | |||
624 | /* | 626 | /* | |
@@ -2055,28 +2057,30 @@ Job_CatchOutput(void) | @@ -2055,28 +2057,30 @@ Job_CatchOutput(void) | |||
2055 | POLL_MSEC); | 2057 | POLL_MSEC); | |
2056 | } while (nready < 0 && errno == EINTR); | 2058 | } while (nready < 0 && errno == EINTR); | |
2057 | 2059 | |||
2058 | if (nready < 0) | 2060 | if (nready < 0) | |
2059 | Punt("poll: %s", strerror(errno)); | 2061 | Punt("poll: %s", strerror(errno)); | |
2060 | 2062 | |||
2061 | if (nready > 0 && readyfd(&childExitJob)) { | 2063 | if (nready > 0 && readyfd(&childExitJob)) { | |
2062 | char token = 0; | 2064 | char token = 0; | |
2063 | ssize_t count; | 2065 | ssize_t count; | |
2064 | count = read(childExitJob.inPipe, &token, 1); | 2066 | count = read(childExitJob.inPipe, &token, 1); | |
2065 | switch (count) { | 2067 | switch (count) { | |
2066 | case 0: | 2068 | case 0: | |
2067 | Punt("unexpected eof on token pipe"); | 2069 | Punt("unexpected eof on token pipe"); | |
2070 | /*NOTREACHED*/ | |||
2068 | case -1: | 2071 | case -1: | |
2069 | Punt("token pipe read: %s", strerror(errno)); | 2072 | Punt("token pipe read: %s", strerror(errno)); | |
2073 | /*NOTREACHED*/ | |||
2070 | case 1: | 2074 | case 1: | |
2071 | if (token == DO_JOB_RESUME[0]) | 2075 | if (token == DO_JOB_RESUME[0]) | |
2072 | /* | 2076 | /* | |
2073 | * Complete relay requested from our SIGCONT | 2077 | * Complete relay requested from our SIGCONT | |
2074 | * handler | 2078 | * handler | |
2075 | */ | 2079 | */ | |
2076 | JobRestartJobs(); | 2080 | JobRestartJobs(); | |
2077 | break; | 2081 | break; | |
2078 | default: | 2082 | default: | |
2079 | abort(); | 2083 | abort(); | |
2080 | } | 2084 | } | |
2081 | nready--; | 2085 | nready--; | |
2082 | } | 2086 | } |
--- src/usr.bin/make/main.c 2021/01/08 21:46:50 1.509
+++ src/usr.bin/make/main.c 2021/01/09 16:06:09 1.510
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main.c,v 1.509 2021/01/08 21:46:50 sjg Exp $ */ | 1 | /* $NetBSD: main.c,v 1.510 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | 4 | * Copyright (c) 1988, 1989, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -100,27 +100,27 @@ | @@ -100,27 +100,27 @@ | |||
100 | 100 | |||
101 | #include <errno.h> | 101 | #include <errno.h> | |
102 | #include <signal.h> | 102 | #include <signal.h> | |
103 | #include <stdarg.h> | 103 | #include <stdarg.h> | |
104 | #include <time.h> | 104 | #include <time.h> | |
105 | 105 | |||
106 | #include "make.h" | 106 | #include "make.h" | |
107 | #include "dir.h" | 107 | #include "dir.h" | |
108 | #include "job.h" | 108 | #include "job.h" | |
109 | #include "pathnames.h" | 109 | #include "pathnames.h" | |
110 | #include "trace.h" | 110 | #include "trace.h" | |
111 | 111 | |||
112 | /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ | 112 | /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ | |
113 | MAKE_RCSID("$NetBSD: main.c,v 1.509 2021/01/08 21:46:50 sjg Exp $"); | 113 | MAKE_RCSID("$NetBSD: main.c,v 1.510 2021/01/09 16:06:09 rillig Exp $"); | |
114 | #if defined(MAKE_NATIVE) && !defined(lint) | 114 | #if defined(MAKE_NATIVE) && !defined(lint) | |
115 | __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " | 115 | __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " | |
116 | "The Regents of the University of California. " | 116 | "The Regents of the University of California. " | |
117 | "All rights reserved."); | 117 | "All rights reserved."); | |
118 | #endif | 118 | #endif | |
119 | 119 | |||
120 | CmdOpts opts; | 120 | CmdOpts opts; | |
121 | time_t now; /* Time at start of make */ | 121 | time_t now; /* Time at start of make */ | |
122 | GNode *defaultNode; /* .DEFAULT node */ | 122 | GNode *defaultNode; /* .DEFAULT node */ | |
123 | Boolean allPrecious; /* .PRECIOUS given on line by itself */ | 123 | Boolean allPrecious; /* .PRECIOUS given on line by itself */ | |
124 | Boolean deleteOnError; /* .DELETE_ON_ERROR: set */ | 124 | Boolean deleteOnError; /* .DELETE_ON_ERROR: set */ | |
125 | 125 | |||
126 | static int maxJobTokens; /* -j argument */ | 126 | static int maxJobTokens; /* -j argument */ | |
@@ -1002,31 +1002,31 @@ static const char * | @@ -1002,31 +1002,31 @@ static const char * | |||
1002 | InitVarMachineArch(void) | 1002 | InitVarMachineArch(void) | |
1003 | { | 1003 | { | |
1004 | const char *env = getenv("MACHINE_ARCH"); | 1004 | const char *env = getenv("MACHINE_ARCH"); | |
1005 | if (env != NULL) | 1005 | if (env != NULL) | |
1006 | return env; | 1006 | return env; | |
1007 | 1007 | |||
1008 | #ifdef MAKE_NATIVE | 1008 | #ifdef MAKE_NATIVE | |
1009 | { | 1009 | { | |
1010 | struct utsname utsname; | 1010 | struct utsname utsname; | |
1011 | static char machine_arch_buf[sizeof utsname.machine]; | 1011 | static char machine_arch_buf[sizeof utsname.machine]; | |
1012 | const int mib[2] = { CTL_HW, HW_MACHINE_ARCH }; | 1012 | const int mib[2] = { CTL_HW, HW_MACHINE_ARCH }; | |
1013 | size_t len = sizeof machine_arch_buf; | 1013 | size_t len = sizeof machine_arch_buf; | |
1014 | 1014 | |||
1015 | if (sysctl(mib, __arraycount(mib), machine_arch_buf, | 1015 | if (sysctl(mib, (unsigned int)__arraycount(mib), | |
1016 | &len, NULL, 0) < 0) { | 1016 | machine_arch_buf, &len, NULL, 0) < 0) { | |
1017 | (void)fprintf(stderr, "%s: sysctl failed (%s).\n", progname, | 1017 | (void)fprintf(stderr, "%s: sysctl failed (%s).\n", | |
1018 | strerror(errno)); | 1018 | progname, strerror(errno)); | |
1019 | exit(2); | 1019 | exit(2); | |
1020 | } | 1020 | } | |
1021 | 1021 | |||
1022 | return machine_arch_buf; | 1022 | return machine_arch_buf; | |
1023 | } | 1023 | } | |
1024 | #elif defined(MACHINE_ARCH) | 1024 | #elif defined(MACHINE_ARCH) | |
1025 | return MACHINE_ARCH; | 1025 | return MACHINE_ARCH; | |
1026 | #elif defined(MAKE_MACHINE_ARCH) | 1026 | #elif defined(MAKE_MACHINE_ARCH) | |
1027 | return MAKE_MACHINE_ARCH; | 1027 | return MAKE_MACHINE_ARCH; | |
1028 | #else | 1028 | #else | |
1029 | return "unknown"; | 1029 | return "unknown"; | |
1030 | #endif | 1030 | #endif | |
1031 | } | 1031 | } | |
1032 | 1032 |
--- src/usr.bin/make/meta.c 2020/12/31 17:39:36 1.166
+++ src/usr.bin/make/meta.c 2021/01/09 16:06:09 1.167
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: meta.c,v 1.166 2020/12/31 17:39:36 rillig Exp $ */ | 1 | /* $NetBSD: meta.c,v 1.167 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Implement 'meta' mode. | 4 | * Implement 'meta' mode. | |
5 | * Adapted from John Birrell's patches to FreeBSD make. | 5 | * Adapted from John Birrell's patches to FreeBSD make. | |
6 | * --sjg | 6 | * --sjg | |
7 | */ | 7 | */ | |
8 | /* | 8 | /* | |
9 | * Copyright (c) 2009-2016, Juniper Networks, Inc. | 9 | * Copyright (c) 2009-2016, Juniper Networks, Inc. | |
10 | * Portions Copyright (c) 2009, John Birrell. | 10 | * Portions Copyright (c) 2009, John Birrell. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -393,27 +393,27 @@ printCMDs(GNode *gn, FILE *fp) | @@ -393,27 +393,27 @@ printCMDs(GNode *gn, FILE *fp) | |||
393 | } | 393 | } | |
394 | 394 | |||
395 | /* | 395 | /* | |
396 | * Certain node types never get a .meta file | 396 | * Certain node types never get a .meta file | |
397 | */ | 397 | */ | |
398 | #define SKIP_META_TYPE(_type) do { \ | 398 | #define SKIP_META_TYPE(_type) do { \ | |
399 | if ((gn->type & __CONCAT(OP_, _type))) { \ | 399 | if ((gn->type & __CONCAT(OP_, _type))) { \ | |
400 | if (verbose) { \ | 400 | if (verbose) { \ | |
401 | debug_printf("Skipping meta for %s: .%s\n", \ | 401 | debug_printf("Skipping meta for %s: .%s\n", \ | |
402 | gn->name, __STRING(_type)); \ | 402 | gn->name, __STRING(_type)); \ | |
403 | } \ | 403 | } \ | |
404 | return FALSE; \ | 404 | return FALSE; \ | |
405 | } \ | 405 | } \ | |
406 | } while (0) | 406 | } while (/*CONSTCOND*/0) | |
407 | 407 | |||
408 | 408 | |||
409 | /* | 409 | /* | |
410 | * Do we need/want a .meta file ? | 410 | * Do we need/want a .meta file ? | |
411 | */ | 411 | */ | |
412 | static Boolean | 412 | static Boolean | |
413 | meta_needed(GNode *gn, const char *dname, | 413 | meta_needed(GNode *gn, const char *dname, | |
414 | char *objdir_realpath, Boolean verbose) | 414 | char *objdir_realpath, Boolean verbose) | |
415 | { | 415 | { | |
416 | struct cached_stat cst; | 416 | struct cached_stat cst; | |
417 | 417 | |||
418 | if (verbose) | 418 | if (verbose) | |
419 | verbose = DEBUG(META); | 419 | verbose = DEBUG(META); | |
@@ -1684,22 +1684,22 @@ meta_compat_parent(pid_t child) | @@ -1684,22 +1684,22 @@ meta_compat_parent(pid_t child) | |||
1684 | /* XXX this is not line-buffered */ | 1684 | /* XXX this is not line-buffered */ | |
1685 | ssize_t nread = read(outfd, buf, sizeof buf - 1); | 1685 | ssize_t nread = read(outfd, buf, sizeof buf - 1); | |
1686 | if (nread == -1) | 1686 | if (nread == -1) | |
1687 | err(1, "read"); | 1687 | err(1, "read"); | |
1688 | if (nread == 0) { | 1688 | if (nread == 0) { | |
1689 | close(outfd); | 1689 | close(outfd); | |
1690 | outfd = -1; | 1690 | outfd = -1; | |
1691 | break; | 1691 | break; | |
1692 | } | 1692 | } | |
1693 | fwrite(buf, 1, (size_t)nread, stdout); | 1693 | fwrite(buf, 1, (size_t)nread, stdout); | |
1694 | fflush(stdout); | 1694 | fflush(stdout); | |
1695 | buf[nread] = '\0'; | 1695 | buf[nread] = '\0'; | |
1696 | meta_job_output(NULL, buf, ""); | 1696 | meta_job_output(NULL, buf, ""); | |
1697 | } while (0); | 1697 | } while (/*CONSTCOND*/0); | |
1698 | if (metafd != -1 && FD_ISSET(metafd, &readfds)) { | 1698 | if (metafd != -1 && FD_ISSET(metafd, &readfds)) { | |
1699 | if (meta_job_event(NULL) <= 0) | 1699 | if (meta_job_event(NULL) <= 0) | |
1700 | metafd = -1; | 1700 | metafd = -1; | |
1701 | } | 1701 | } | |
1702 | } | 1702 | } | |
1703 | } | 1703 | } | |
1704 | 1704 | |||
1705 | #endif /* USE_META */ | 1705 | #endif /* USE_META */ |
--- src/usr.bin/make/suff.c 2020/12/30 10:03:16 1.333
+++ src/usr.bin/make/suff.c 2021/01/09 16:06:09 1.334
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: suff.c,v 1.333 2020/12/30 10:03:16 rillig Exp $ */ | 1 | /* $NetBSD: suff.c,v 1.334 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | 4 | * Copyright (c) 1988, 1989, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -104,27 +104,27 @@ | @@ -104,27 +104,27 @@ | |||
104 | * Suff_FindDeps Find implicit sources for and the location of | 104 | * Suff_FindDeps Find implicit sources for and the location of | |
105 | * a target based on its suffix. Returns the | 105 | * a target based on its suffix. Returns the | |
106 | * bottom-most node added to the graph or NULL | 106 | * bottom-most node added to the graph or NULL | |
107 | * if the target had no implicit sources. | 107 | * if the target had no implicit sources. | |
108 | * | 108 | * | |
109 | * Suff_FindPath Return the appropriate path to search in order to | 109 | * Suff_FindPath Return the appropriate path to search in order to | |
110 | * find the node. | 110 | * find the node. | |
111 | */ | 111 | */ | |
112 | 112 | |||
113 | #include "make.h" | 113 | #include "make.h" | |
114 | #include "dir.h" | 114 | #include "dir.h" | |
115 | 115 | |||
116 | /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ | 116 | /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ | |
117 | MAKE_RCSID("$NetBSD: suff.c,v 1.333 2020/12/30 10:03:16 rillig Exp $"); | 117 | MAKE_RCSID("$NetBSD: suff.c,v 1.334 2021/01/09 16:06:09 rillig Exp $"); | |
118 | 118 | |||
119 | typedef List SuffixList; | 119 | typedef List SuffixList; | |
120 | typedef ListNode SuffixListNode; | 120 | typedef ListNode SuffixListNode; | |
121 | 121 | |||
122 | typedef List CandidateList; | 122 | typedef List CandidateList; | |
123 | typedef ListNode CandidateListNode; | 123 | typedef ListNode CandidateListNode; | |
124 | 124 | |||
125 | /* The defined suffixes, such as '.c', '.o', '.l'. */ | 125 | /* The defined suffixes, such as '.c', '.o', '.l'. */ | |
126 | static SuffixList sufflist = LST_INIT; | 126 | static SuffixList sufflist = LST_INIT; | |
127 | #ifdef CLEANUP | 127 | #ifdef CLEANUP | |
128 | /* The suffixes to be cleaned up at the end. */ | 128 | /* The suffixes to be cleaned up at the end. */ | |
129 | static SuffixList suffClean = LST_INIT; | 129 | static SuffixList suffClean = LST_INIT; | |
130 | #endif | 130 | #endif | |
@@ -605,26 +605,27 @@ Suff_AddTransform(const char *name) | @@ -605,26 +605,27 @@ Suff_AddTransform(const char *name) | |||
605 | * don't actually free the commands themselves, because a | 605 | * don't actually free the commands themselves, because a | |
606 | * given command can be attached to several different | 606 | * given command can be attached to several different | |
607 | * transformations. | 607 | * transformations. | |
608 | */ | 608 | */ | |
609 | Lst_Done(&gn->commands); | 609 | Lst_Done(&gn->commands); | |
610 | Lst_Init(&gn->commands); | 610 | Lst_Init(&gn->commands); | |
611 | Lst_Done(&gn->children); | 611 | Lst_Done(&gn->children); | |
612 | Lst_Init(&gn->children); | 612 | Lst_Init(&gn->children); | |
613 | } | 613 | } | |
614 | 614 | |||
615 | gn->type = OP_TRANSFORM; | 615 | gn->type = OP_TRANSFORM; | |
616 | 616 | |||
617 | { | 617 | { | |
618 | /* TODO: Avoid the redundant parsing here. */ | |||
618 | Boolean ok = ParseTransform(name, &srcSuff, &targSuff); | 619 | Boolean ok = ParseTransform(name, &srcSuff, &targSuff); | |
619 | assert(ok); | 620 | assert(ok); | |
620 | (void)ok; | 621 | (void)ok; | |
621 | } | 622 | } | |
622 | 623 | |||
623 | /* Link the two together in the proper relationship and order. */ | 624 | /* Link the two together in the proper relationship and order. */ | |
624 | DEBUG2(SUFF, "defining transformation from `%s' to `%s'\n", | 625 | DEBUG2(SUFF, "defining transformation from `%s' to `%s'\n", | |
625 | srcSuff->name, targSuff->name); | 626 | srcSuff->name, targSuff->name); | |
626 | Relate(srcSuff, targSuff); | 627 | Relate(srcSuff, targSuff); | |
627 | 628 | |||
628 | return gn; | 629 | return gn; | |
629 | } | 630 | } | |
630 | 631 | |||
@@ -1002,26 +1003,27 @@ Candidate_New(char *name, char *prefix, | @@ -1002,26 +1003,27 @@ Candidate_New(char *name, char *prefix, | |||
1002 | cand->prefix = prefix; | 1003 | cand->prefix = prefix; | |
1003 | cand->suff = Suffix_Ref(suff); | 1004 | cand->suff = Suffix_Ref(suff); | |
1004 | cand->parent = parent; | 1005 | cand->parent = parent; | |
1005 | cand->node = gn; | 1006 | cand->node = gn; | |
1006 | cand->numChildren = 0; | 1007 | cand->numChildren = 0; | |
1007 | #ifdef DEBUG_SRC | 1008 | #ifdef DEBUG_SRC | |
1008 | Lst_Init(&cand->childrenList); | 1009 | Lst_Init(&cand->childrenList); | |
1009 | #endif | 1010 | #endif | |
1010 | 1011 | |||
1011 | return cand; | 1012 | return cand; | |
1012 | } | 1013 | } | |
1013 | 1014 | |||
1014 | /* Add a new candidate to the list. */ | 1015 | /* Add a new candidate to the list. */ | |
1016 | /*ARGSUSED*/ | |||
1015 | static void | 1017 | static void | |
1016 | CandidateList_Add(CandidateList *list, char *srcName, Candidate *targ, | 1018 | CandidateList_Add(CandidateList *list, char *srcName, Candidate *targ, | |
1017 | Suffix *suff, const char *debug_tag) | 1019 | Suffix *suff, const char *debug_tag) | |
1018 | { | 1020 | { | |
1019 | Candidate *cand = Candidate_New(srcName, targ->prefix, suff, targ, | 1021 | Candidate *cand = Candidate_New(srcName, targ->prefix, suff, targ, | |
1020 | NULL); | 1022 | NULL); | |
1021 | targ->numChildren++; | 1023 | targ->numChildren++; | |
1022 | Lst_Append(list, cand); | 1024 | Lst_Append(list, cand); | |
1023 | 1025 | |||
1024 | #ifdef DEBUG_SRC | 1026 | #ifdef DEBUG_SRC | |
1025 | Lst_Append(&targ->childrenList, cand); | 1027 | Lst_Append(&targ->childrenList, cand); | |
1026 | debug_printf("%s add suff %p:%s candidate %p:%s to list %p:", | 1028 | debug_printf("%s add suff %p:%s candidate %p:%s to list %p:", | |
1027 | debug_tag, targ, targ->file, cand, cand->file, list); | 1029 | debug_tag, targ, targ->file, cand, cand->file, list); |
--- src/usr.bin/make/var.c 2020/12/30 10:03:16 1.778
+++ src/usr.bin/make/var.c 2021/01/09 16:06:09 1.779
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: var.c,v 1.778 2020/12/30 10:03:16 rillig Exp $ */ | 1 | /* $NetBSD: var.c,v 1.779 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | 4 | * Copyright (c) 1988, 1989, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Adam de Boor. | 8 | * Adam de Boor. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -121,27 +121,27 @@ | @@ -121,27 +121,27 @@ | |||
121 | #include <regex.h> | 121 | #include <regex.h> | |
122 | #endif | 122 | #endif | |
123 | #include <errno.h> | 123 | #include <errno.h> | |
124 | #include <inttypes.h> | 124 | #include <inttypes.h> | |
125 | #include <limits.h> | 125 | #include <limits.h> | |
126 | #include <time.h> | 126 | #include <time.h> | |
127 | 127 | |||
128 | #include "make.h" | 128 | #include "make.h" | |
129 | #include "dir.h" | 129 | #include "dir.h" | |
130 | #include "job.h" | 130 | #include "job.h" | |
131 | #include "metachar.h" | 131 | #include "metachar.h" | |
132 | 132 | |||
133 | /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ | 133 | /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ | |
134 | MAKE_RCSID("$NetBSD: var.c,v 1.778 2020/12/30 10:03:16 rillig Exp $"); | 134 | MAKE_RCSID("$NetBSD: var.c,v 1.779 2021/01/09 16:06:09 rillig Exp $"); | |
135 | 135 | |||
136 | typedef enum VarFlags { | 136 | typedef enum VarFlags { | |
137 | VAR_NONE = 0, | 137 | VAR_NONE = 0, | |
138 | 138 | |||
139 | /* | 139 | /* | |
140 | * The variable's value is currently being used by Var_Parse or | 140 | * The variable's value is currently being used by Var_Parse or | |
141 | * Var_Subst. This marker is used to avoid endless recursion. | 141 | * Var_Subst. This marker is used to avoid endless recursion. | |
142 | */ | 142 | */ | |
143 | VAR_IN_USE = 0x01, | 143 | VAR_IN_USE = 0x01, | |
144 | 144 | |||
145 | /* | 145 | /* | |
146 | * The variable comes from the environment. | 146 | * The variable comes from the environment. | |
147 | * These variables are not registered in any GNode, therefore they | 147 | * These variables are not registered in any GNode, therefore they | |
@@ -1225,62 +1225,66 @@ SepBuf_Destroy(SepBuf *buf, Boolean free | @@ -1225,62 +1225,66 @@ SepBuf_Destroy(SepBuf *buf, Boolean free | |||
1225 | * and typically adds a modification of this word to the buffer. It may also | 1225 | * and typically adds a modification of this word to the buffer. It may also | |
1226 | * do nothing or add several words. | 1226 | * do nothing or add several words. | |
1227 | * | 1227 | * | |
1228 | * For example, in ${:Ua b c:M*2}, the callback is called 3 times, once for | 1228 | * For example, in ${:Ua b c:M*2}, the callback is called 3 times, once for | |
1229 | * each word of "a b c". | 1229 | * each word of "a b c". | |
1230 | */ | 1230 | */ | |
1231 | typedef void (*ModifyWordsCallback)(const char *word, SepBuf *buf, void *data); | 1231 | typedef void (*ModifyWordsCallback)(const char *word, SepBuf *buf, void *data); | |
1232 | 1232 | |||
1233 | 1233 | |||
1234 | /* | 1234 | /* | |
1235 | * Callback for ModifyWords to implement the :H modifier. | 1235 | * Callback for ModifyWords to implement the :H modifier. | |
1236 | * Add the dirname of the given word to the buffer. | 1236 | * Add the dirname of the given word to the buffer. | |
1237 | */ | 1237 | */ | |
1238 | /*ARGSUSED*/ | |||
1238 | static void | 1239 | static void | |
1239 | ModifyWord_Head(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | 1240 | ModifyWord_Head(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | |
1240 | { | 1241 | { | |
1241 | const char *slash = strrchr(word, '/'); | 1242 | const char *slash = strrchr(word, '/'); | |
1242 | if (slash != NULL) | 1243 | if (slash != NULL) | |
1243 | SepBuf_AddBytesBetween(buf, word, slash); | 1244 | SepBuf_AddBytesBetween(buf, word, slash); | |
1244 | else | 1245 | else | |
1245 | SepBuf_AddStr(buf, "."); | 1246 | SepBuf_AddStr(buf, "."); | |
1246 | } | 1247 | } | |
1247 | 1248 | |||
1248 | /* | 1249 | /* | |
1249 | * Callback for ModifyWords to implement the :T modifier. | 1250 | * Callback for ModifyWords to implement the :T modifier. | |
1250 | * Add the basename of the given word to the buffer. | 1251 | * Add the basename of the given word to the buffer. | |
1251 | */ | 1252 | */ | |
1253 | /*ARGSUSED*/ | |||
1252 | static void | 1254 | static void | |
1253 | ModifyWord_Tail(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | 1255 | ModifyWord_Tail(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | |
1254 | { | 1256 | { | |
1255 | SepBuf_AddStr(buf, str_basename(word)); | 1257 | SepBuf_AddStr(buf, str_basename(word)); | |
1256 | } | 1258 | } | |
1257 | 1259 | |||
1258 | /* | 1260 | /* | |
1259 | * Callback for ModifyWords to implement the :E modifier. | 1261 | * Callback for ModifyWords to implement the :E modifier. | |
1260 | * Add the filename suffix of the given word to the buffer, if it exists. | 1262 | * Add the filename suffix of the given word to the buffer, if it exists. | |
1261 | */ | 1263 | */ | |
1264 | /*ARGSUSED*/ | |||
1262 | static void | 1265 | static void | |
1263 | ModifyWord_Suffix(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | 1266 | ModifyWord_Suffix(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | |
1264 | { | 1267 | { | |
1265 | const char *lastDot = strrchr(word, '.'); | 1268 | const char *lastDot = strrchr(word, '.'); | |
1266 | if (lastDot != NULL) | 1269 | if (lastDot != NULL) | |
1267 | SepBuf_AddStr(buf, lastDot + 1); | 1270 | SepBuf_AddStr(buf, lastDot + 1); | |
1268 | } | 1271 | } | |
1269 | 1272 | |||
1270 | /* | 1273 | /* | |
1271 | * Callback for ModifyWords to implement the :R modifier. | 1274 | * Callback for ModifyWords to implement the :R modifier. | |
1272 | * Add the basename of the given word to the buffer. | 1275 | * Add the basename of the given word to the buffer. | |
1273 | */ | 1276 | */ | |
1277 | /*ARGSUSED*/ | |||
1274 | static void | 1278 | static void | |
1275 | ModifyWord_Root(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | 1279 | ModifyWord_Root(const char *word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED) | |
1276 | { | 1280 | { | |
1277 | const char *lastDot = strrchr(word, '.'); | 1281 | const char *lastDot = strrchr(word, '.'); | |
1278 | size_t len = lastDot != NULL ? (size_t)(lastDot - word) : strlen(word); | 1282 | size_t len = lastDot != NULL ? (size_t)(lastDot - word) : strlen(word); | |
1279 | SepBuf_AddBytes(buf, word, len); | 1283 | SepBuf_AddBytes(buf, word, len); | |
1280 | } | 1284 | } | |
1281 | 1285 | |||
1282 | /* | 1286 | /* | |
1283 | * Callback for ModifyWords to implement the :M modifier. | 1287 | * Callback for ModifyWords to implement the :M modifier. | |
1284 | * Place the word in the buffer if it matches the given pattern. | 1288 | * Place the word in the buffer if it matches the given pattern. | |
1285 | */ | 1289 | */ | |
1286 | static void | 1290 | static void | |
@@ -1680,26 +1684,27 @@ VarSelectWords(char sep, Boolean oneBigW | @@ -1680,26 +1684,27 @@ VarSelectWords(char sep, Boolean oneBigW | |||
1680 | SepBuf_Sep(&buf); | 1684 | SepBuf_Sep(&buf); | |
1681 | } | 1685 | } | |
1682 | 1686 | |||
1683 | Words_Free(words); | 1687 | Words_Free(words); | |
1684 | 1688 | |||
1685 | return SepBuf_Destroy(&buf, FALSE); | 1689 | return SepBuf_Destroy(&buf, FALSE); | |
1686 | } | 1690 | } | |
1687 | 1691 | |||
1688 | 1692 | |||
1689 | /* | 1693 | /* | |
1690 | * Callback for ModifyWords to implement the :tA modifier. | 1694 | * Callback for ModifyWords to implement the :tA modifier. | |
1691 | * Replace each word with the result of realpath() if successful. | 1695 | * Replace each word with the result of realpath() if successful. | |
1692 | */ | 1696 | */ | |
1697 | /*ARGSUSED*/ | |||
1693 | static void | 1698 | static void | |
1694 | ModifyWord_Realpath(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED) | 1699 | ModifyWord_Realpath(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED) | |
1695 | { | 1700 | { | |
1696 | struct stat st; | 1701 | struct stat st; | |
1697 | char rbuf[MAXPATHLEN]; | 1702 | char rbuf[MAXPATHLEN]; | |
1698 | 1703 | |||
1699 | const char *rp = cached_realpath(word, rbuf); | 1704 | const char *rp = cached_realpath(word, rbuf); | |
1700 | if (rp != NULL && *rp == '/' && stat(rp, &st) == 0) | 1705 | if (rp != NULL && *rp == '/' && stat(rp, &st) == 0) | |
1701 | word = rp; | 1706 | word = rp; | |
1702 | 1707 | |||
1703 | SepBuf_AddStr(buf, word); | 1708 | SepBuf_AddStr(buf, word); | |
1704 | } | 1709 | } | |
1705 | 1710 | |||
@@ -2779,26 +2784,27 @@ ApplyModifier_Regex(const char **pp, con | @@ -2779,26 +2784,27 @@ ApplyModifier_Regex(const char **pp, con | |||
2779 | 2784 | |||
2780 | /* :Q, :q */ | 2785 | /* :Q, :q */ | |
2781 | static ApplyModifierResult | 2786 | static ApplyModifierResult | |
2782 | ApplyModifier_Quote(const char **pp, const char *val, ApplyModifiersState *st) | 2787 | ApplyModifier_Quote(const char **pp, const char *val, ApplyModifiersState *st) | |
2783 | { | 2788 | { | |
2784 | if ((*pp)[1] == st->endc || (*pp)[1] == ':') { | 2789 | if ((*pp)[1] == st->endc || (*pp)[1] == ':') { | |
2785 | st->newVal = FStr_InitOwn(VarQuote(val, **pp == 'q')); | 2790 | st->newVal = FStr_InitOwn(VarQuote(val, **pp == 'q')); | |
2786 | (*pp)++; | 2791 | (*pp)++; | |
2787 | return AMR_OK; | 2792 | return AMR_OK; | |
2788 | } else | 2793 | } else | |
2789 | return AMR_UNKNOWN; | 2794 | return AMR_UNKNOWN; | |
2790 | } | 2795 | } | |
2791 | 2796 | |||
2797 | /*ARGSUSED*/ | |||
2792 | static void | 2798 | static void | |
2793 | ModifyWord_Copy(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED) | 2799 | ModifyWord_Copy(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED) | |
2794 | { | 2800 | { | |
2795 | SepBuf_AddStr(buf, word); | 2801 | SepBuf_AddStr(buf, word); | |
2796 | } | 2802 | } | |
2797 | 2803 | |||
2798 | /* :ts<separator> */ | 2804 | /* :ts<separator> */ | |
2799 | static ApplyModifierResult | 2805 | static ApplyModifierResult | |
2800 | ApplyModifier_ToSep(const char **pp, const char *val, ApplyModifiersState *st) | 2806 | ApplyModifier_ToSep(const char **pp, const char *val, ApplyModifiersState *st) | |
2801 | { | 2807 | { | |
2802 | const char *sep = *pp + 2; | 2808 | const char *sep = *pp + 2; | |
2803 | 2809 | |||
2804 | /* ":ts<any><endc>" or ":ts<any>:" */ | 2810 | /* ":ts<any><endc>" or ":ts<any>:" */ | |
@@ -3095,27 +3101,27 @@ ApplyModifier_Order(const char **pp, con | @@ -3095,27 +3101,27 @@ ApplyModifier_Order(const char **pp, con | |||
3095 | } else | 3101 | } else | |
3096 | ShuffleStrings(words.words, words.len); | 3102 | ShuffleStrings(words.words, words.len); | |
3097 | } else { | 3103 | } else { | |
3098 | Words_Free(words); | 3104 | Words_Free(words); | |
3099 | return AMR_BAD; | 3105 | return AMR_BAD; | |
3100 | } | 3106 | } | |
3101 | 3107 | |||
3102 | st->newVal = FStr_InitOwn(Words_JoinFree(words)); | 3108 | st->newVal = FStr_InitOwn(Words_JoinFree(words)); | |
3103 | return AMR_OK; | 3109 | return AMR_OK; | |
3104 | } | 3110 | } | |
3105 | 3111 | |||
3106 | /* :? then : else */ | 3112 | /* :? then : else */ | |
3107 | static ApplyModifierResult | 3113 | static ApplyModifierResult | |
3108 | ApplyModifier_IfElse(const char **pp, const char *val, ApplyModifiersState *st) | 3114 | ApplyModifier_IfElse(const char **pp, ApplyModifiersState *st) | |
3109 | { | 3115 | { | |
3110 | char *then_expr, *else_expr; | 3116 | char *then_expr, *else_expr; | |
3111 | VarParseResult res; | 3117 | VarParseResult res; | |
3112 | 3118 | |||
3113 | Boolean value = FALSE; | 3119 | Boolean value = FALSE; | |
3114 | VarEvalFlags then_eflags = VARE_NONE; | 3120 | VarEvalFlags then_eflags = VARE_NONE; | |
3115 | VarEvalFlags else_eflags = VARE_NONE; | 3121 | VarEvalFlags else_eflags = VARE_NONE; | |
3116 | 3122 | |||
3117 | int cond_rc = COND_PARSE; /* anything other than COND_INVALID */ | 3123 | int cond_rc = COND_PARSE; /* anything other than COND_INVALID */ | |
3118 | if (st->eflags & VARE_WANTRES) { | 3124 | if (st->eflags & VARE_WANTRES) { | |
3119 | cond_rc = Cond_EvalCondition(st->var->name.str, &value); | 3125 | cond_rc = Cond_EvalCondition(st->var->name.str, &value); | |
3120 | if (cond_rc != COND_INVALID && value) | 3126 | if (cond_rc != COND_INVALID && value) | |
3121 | then_eflags = st->eflags; | 3127 | then_eflags = st->eflags; | |
@@ -3451,27 +3457,27 @@ ApplyModifier(const char **pp, const cha | @@ -3451,27 +3457,27 @@ ApplyModifier(const char **pp, const cha | |||
3451 | return ApplyModifier_Gmtime(pp, val, st); | 3457 | return ApplyModifier_Gmtime(pp, val, st); | |
3452 | case 'h': | 3458 | case 'h': | |
3453 | return ApplyModifier_Hash(pp, val, st); | 3459 | return ApplyModifier_Hash(pp, val, st); | |
3454 | case 'l': | 3460 | case 'l': | |
3455 | return ApplyModifier_Localtime(pp, val, st); | 3461 | return ApplyModifier_Localtime(pp, val, st); | |
3456 | case 't': | 3462 | case 't': | |
3457 | return ApplyModifier_To(pp, val, st); | 3463 | return ApplyModifier_To(pp, val, st); | |
3458 | case 'N': | 3464 | case 'N': | |
3459 | case 'M': | 3465 | case 'M': | |
3460 | return ApplyModifier_Match(pp, val, st); | 3466 | return ApplyModifier_Match(pp, val, st); | |
3461 | case 'S': | 3467 | case 'S': | |
3462 | return ApplyModifier_Subst(pp, val, st); | 3468 | return ApplyModifier_Subst(pp, val, st); | |
3463 | case '?': | 3469 | case '?': | |
3464 | return ApplyModifier_IfElse(pp, val, st); | 3470 | return ApplyModifier_IfElse(pp, st); | |
3465 | #ifndef NO_REGEX | 3471 | #ifndef NO_REGEX | |
3466 | case 'C': | 3472 | case 'C': | |
3467 | return ApplyModifier_Regex(pp, val, st); | 3473 | return ApplyModifier_Regex(pp, val, st); | |
3468 | #endif | 3474 | #endif | |
3469 | case 'q': | 3475 | case 'q': | |
3470 | case 'Q': | 3476 | case 'Q': | |
3471 | return ApplyModifier_Quote(pp, val, st); | 3477 | return ApplyModifier_Quote(pp, val, st); | |
3472 | case 'T': | 3478 | case 'T': | |
3473 | return ApplyModifier_WordFunc(pp, val, st, ModifyWord_Tail); | 3479 | return ApplyModifier_WordFunc(pp, val, st, ModifyWord_Tail); | |
3474 | case 'H': | 3480 | case 'H': | |
3475 | return ApplyModifier_WordFunc(pp, val, st, ModifyWord_Head); | 3481 | return ApplyModifier_WordFunc(pp, val, st, ModifyWord_Head); | |
3476 | case 'E': | 3482 | case 'E': | |
3477 | return ApplyModifier_WordFunc(pp, val, st, ModifyWord_Suffix); | 3483 | return ApplyModifier_WordFunc(pp, val, st, ModifyWord_Suffix); |
--- src/usr.bin/make/filemon/filemon_ktrace.c 2020/12/31 17:39:36 1.9
+++ src/usr.bin/make/filemon/filemon_ktrace.c 2021/01/09 16:06:09 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: filemon_ktrace.c,v 1.9 2020/12/31 17:39:36 rillig Exp $ */ | 1 | /* $NetBSD: filemon_ktrace.c,v 1.10 2021/01/09 16:06:09 rillig Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2019 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2019 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -120,43 +120,45 @@ struct filemon_state { | @@ -120,43 +120,45 @@ struct filemon_state { | |||
120 | struct filemon_key { | 120 | struct filemon_key { | |
121 | pid_t pid; | 121 | pid_t pid; | |
122 | lwpid_t lid; | 122 | lwpid_t lid; | |
123 | } key; | 123 | } key; | |
124 | struct rb_node node; | 124 | struct rb_node node; | |
125 | int syscode; | 125 | int syscode; | |
126 | void (*show)(struct filemon *, const struct filemon_state *, | 126 | void (*show)(struct filemon *, const struct filemon_state *, | |
127 | const struct ktr_sysret *); | 127 | const struct ktr_sysret *); | |
128 | unsigned i; | 128 | unsigned i; | |
129 | unsigned npath; | 129 | unsigned npath; | |
130 | char *path[/*npath*/]; | 130 | char *path[/*npath*/]; | |
131 | }; | 131 | }; | |
132 | 132 | |||
133 | /*ARGSUSED*/ | |||
133 | static int | 134 | static int | |
134 | compare_filemon_states(void *cookie, const void *na, const void *nb) | 135 | compare_filemon_states(void *cookie, const void *na, const void *nb) | |
135 | { | 136 | { | |
136 | const struct filemon_state *Sa = na; | 137 | const struct filemon_state *Sa = na; | |
137 | const struct filemon_state *Sb = nb; | 138 | const struct filemon_state *Sb = nb; | |
138 | 139 | |||
139 | if (Sa->key.pid < Sb->key.pid) | 140 | if (Sa->key.pid < Sb->key.pid) | |
140 | return -1; | 141 | return -1; | |
141 | if (Sa->key.pid > Sb->key.pid) | 142 | if (Sa->key.pid > Sb->key.pid) | |
142 | return +1; | 143 | return +1; | |
143 | if (Sa->key.lid < Sb->key.lid) | 144 | if (Sa->key.lid < Sb->key.lid) | |
144 | return -1; | 145 | return -1; | |
145 | if (Sa->key.lid > Sb->key.lid) | 146 | if (Sa->key.lid > Sb->key.lid) | |
146 | return +1; | 147 | return +1; | |
147 | return 0; | 148 | return 0; | |
148 | } | 149 | } | |
149 | 150 | |||
151 | /*ARGSUSED*/ | |||
150 | static int | 152 | static int | |
151 | compare_filemon_key(void *cookie, const void *n, const void *k) | 153 | compare_filemon_key(void *cookie, const void *n, const void *k) | |
152 | { | 154 | { | |
153 | const struct filemon_state *S = n; | 155 | const struct filemon_state *S = n; | |
154 | const struct filemon_key *key = k; | 156 | const struct filemon_key *key = k; | |
155 | 157 | |||
156 | if (S->key.pid < key->pid) | 158 | if (S->key.pid < key->pid) | |
157 | return -1; | 159 | return -1; | |
158 | if (S->key.pid > key->pid) | 160 | if (S->key.pid > key->pid) | |
159 | return +1; | 161 | return +1; | |
160 | if (S->key.lid < key->lid) | 162 | if (S->key.lid < key->lid) | |
161 | return -1; | 163 | return -1; | |
162 | if (S->key.lid > key->lid) | 164 | if (S->key.lid > key->lid) | |
@@ -571,27 +573,27 @@ top: /* If the child has exited, nothing | @@ -571,27 +573,27 @@ top: /* If the child has exited, nothing | |||
571 | goto top; | 573 | goto top; | |
572 | default: /* paranoia */ | 574 | default: /* paranoia */ | |
573 | F->state = FILEMON_ERROR; | 575 | F->state = FILEMON_ERROR; | |
574 | /*FALLTHROUGH*/ | 576 | /*FALLTHROUGH*/ | |
575 | case FILEMON_ERROR: /* persistent error indicator */ | 577 | case FILEMON_ERROR: /* persistent error indicator */ | |
576 | F->p = NULL; | 578 | F->p = NULL; | |
577 | F->resid = 0; | 579 | F->resid = 0; | |
578 | errno = EIO; | 580 | errno = EIO; | |
579 | return -1; | 581 | return -1; | |
580 | } | 582 | } | |
581 | } | 583 | } | |
582 | 584 | |||
583 | static struct filemon_state * | 585 | static struct filemon_state * | |
584 | syscall_enter(struct filemon *F, | 586 | syscall_enter( | |
585 | const struct filemon_key *key, const struct ktr_syscall *call, | 587 | const struct filemon_key *key, const struct ktr_syscall *call, | |
586 | unsigned npath, | 588 | unsigned npath, | |
587 | void (*show)(struct filemon *, const struct filemon_state *, | 589 | void (*show)(struct filemon *, const struct filemon_state *, | |
588 | const struct ktr_sysret *)) | 590 | const struct ktr_sysret *)) | |
589 | { | 591 | { | |
590 | struct filemon_state *S; | 592 | struct filemon_state *S; | |
591 | unsigned i; | 593 | unsigned i; | |
592 | 594 | |||
593 | S = calloc(1, offsetof(struct filemon_state, path[npath])); | 595 | S = calloc(1, offsetof(struct filemon_state, path[npath])); | |
594 | if (S == NULL) | 596 | if (S == NULL) | |
595 | return NULL; | 597 | return NULL; | |
596 | S->key = *key; | 598 | S->key = *key; | |
597 | S->show = show; | 599 | S->show = show; | |
@@ -653,27 +655,27 @@ show_retval(struct filemon *F, const str | @@ -653,27 +655,27 @@ show_retval(struct filemon *F, const str | |||
653 | } | 655 | } | |
654 | 656 | |||
655 | static void | 657 | static void | |
656 | show_chdir(struct filemon *F, const struct filemon_state *S, | 658 | show_chdir(struct filemon *F, const struct filemon_state *S, | |
657 | const struct ktr_sysret *ret) | 659 | const struct ktr_sysret *ret) | |
658 | { | 660 | { | |
659 | show_paths(F, S, ret, "C"); | 661 | show_paths(F, S, ret, "C"); | |
660 | } | 662 | } | |
661 | 663 | |||
662 | static void | 664 | static void | |
663 | show_execve(struct filemon *F, const struct filemon_state *S, | 665 | show_execve(struct filemon *F, const struct filemon_state *S, | |
664 | const struct ktr_sysret *ret) | 666 | const struct ktr_sysret *ret) | |
665 | { | 667 | { | |
666 | return show_paths(F, S, ret, "E"); | 668 | show_paths(F, S, ret, "E"); | |
667 | } | 669 | } | |
668 | 670 | |||
669 | static void | 671 | static void | |
670 | show_fork(struct filemon *F, const struct filemon_state *S, | 672 | show_fork(struct filemon *F, const struct filemon_state *S, | |
671 | const struct ktr_sysret *ret) | 673 | const struct ktr_sysret *ret) | |
672 | { | 674 | { | |
673 | show_retval(F, S, ret, "F"); | 675 | show_retval(F, S, ret, "F"); | |
674 | } | 676 | } | |
675 | 677 | |||
676 | static void | 678 | static void | |
677 | show_link(struct filemon *F, const struct filemon_state *S, | 679 | show_link(struct filemon *F, const struct filemon_state *S, | |
678 | const struct ktr_sysret *ret) | 680 | const struct ktr_sysret *ret) | |
679 | { | 681 | { | |
@@ -741,137 +743,143 @@ static void | @@ -741,137 +743,143 @@ static void | |||
741 | show_unlink(struct filemon *F, const struct filemon_state *S, | 743 | show_unlink(struct filemon *F, const struct filemon_state *S, | |
742 | const struct ktr_sysret *ret) | 744 | const struct ktr_sysret *ret) | |
743 | { | 745 | { | |
744 | show_paths(F, S, ret, "D"); | 746 | show_paths(F, S, ret, "D"); | |
745 | } | 747 | } | |
746 | 748 | |||
747 | static void | 749 | static void | |
748 | show_rename(struct filemon *F, const struct filemon_state *S, | 750 | show_rename(struct filemon *F, const struct filemon_state *S, | |
749 | const struct ktr_sysret *ret) | 751 | const struct ktr_sysret *ret) | |
750 | { | 752 | { | |
751 | show_paths(F, S, ret, "M"); | 753 | show_paths(F, S, ret, "M"); | |
752 | } | 754 | } | |
753 | 755 | |||
756 | /*ARGSUSED*/ | |||
754 | static struct filemon_state * | 757 | static struct filemon_state * | |
755 | filemon_sys_chdir(struct filemon *F, const struct filemon_key *key, | 758 | filemon_sys_chdir(struct filemon *F, const struct filemon_key *key, | |
756 | const struct ktr_syscall *call) | 759 | const struct ktr_syscall *call) | |
757 | { | 760 | { | |
758 | return syscall_enter(F, key, call, 1, &show_chdir); | 761 | return syscall_enter(key, call, 1, &show_chdir); | |
759 | } | 762 | } | |
760 | 763 | |||
764 | /*ARGSUSED*/ | |||
761 | static struct filemon_state * | 765 | static struct filemon_state * | |
762 | filemon_sys_execve(struct filemon *F, const struct filemon_key *key, | 766 | filemon_sys_execve(struct filemon *F, const struct filemon_key *key, | |
763 | const struct ktr_syscall *call) | 767 | const struct ktr_syscall *call) | |
764 | { | 768 | { | |
765 | return syscall_enter(F, key, call, 1, &show_execve); | 769 | return syscall_enter(key, call, 1, &show_execve); | |
766 | } | 770 | } | |
767 | 771 | |||
768 | static struct filemon_state * | 772 | static struct filemon_state * | |
769 | filemon_sys_exit(struct filemon *F, const struct filemon_key *key, | 773 | filemon_sys_exit(struct filemon *F, const struct filemon_key *key, | |
770 | const struct ktr_syscall *call) | 774 | const struct ktr_syscall *call) | |
771 | { | 775 | { | |
772 | const register_t *args = (const void *)&call[1]; | 776 | const register_t *args = (const void *)&call[1]; | |
773 | int status = (int)args[0]; | 777 | int status = (int)args[0]; | |
774 | 778 | |||
775 | if (F->out != NULL) { | 779 | if (F->out != NULL) { | |
776 | fprintf(F->out, "X %jd %d\n", (intmax_t)key->pid, status); | 780 | fprintf(F->out, "X %jd %d\n", (intmax_t)key->pid, status); | |
777 | if (key->pid == F->child) { | 781 | if (key->pid == F->child) { | |
778 | fprintf(F->out, "# Bye bye\n"); | 782 | fprintf(F->out, "# Bye bye\n"); | |
779 | F->child = 0; | 783 | F->child = 0; | |
780 | } | 784 | } | |
781 | } | 785 | } | |
782 | return NULL; | 786 | return NULL; | |
783 | } | 787 | } | |
784 | 788 | |||
789 | /*ARGSUSED*/ | |||
785 | static struct filemon_state * | 790 | static struct filemon_state * | |
786 | filemon_sys_fork(struct filemon *F, const struct filemon_key *key, | 791 | filemon_sys_fork(struct filemon *F, const struct filemon_key *key, | |
787 | const struct ktr_syscall *call) | 792 | const struct ktr_syscall *call) | |
788 | { | 793 | { | |
789 | return syscall_enter(F, key, call, 0, &show_fork); | 794 | return syscall_enter(key, call, 0, &show_fork); | |
790 | } | 795 | } | |
791 | 796 | |||
797 | /*ARGSUSED*/ | |||
792 | static struct filemon_state * | 798 | static struct filemon_state * | |
793 | filemon_sys_link(struct filemon *F, const struct filemon_key *key, | 799 | filemon_sys_link(struct filemon *F, const struct filemon_key *key, | |
794 | const struct ktr_syscall *call) | 800 | const struct ktr_syscall *call) | |
795 | { | 801 | { | |
796 | return syscall_enter(F, key, call, 2, &show_link); | 802 | return syscall_enter(key, call, 2, &show_link); | |
797 | } | 803 | } | |
798 | 804 | |||
805 | /*ARGSUSED*/ | |||
799 | static struct filemon_state * | 806 | static struct filemon_state * | |
800 | filemon_sys_open(struct filemon *F, const struct filemon_key *key, | 807 | filemon_sys_open(struct filemon *F, const struct filemon_key *key, | |
801 | const struct ktr_syscall *call) | 808 | const struct ktr_syscall *call) | |
802 | { | 809 | { | |
803 | const register_t *args = (const void *)&call[1]; | 810 | const register_t *args = (const void *)&call[1]; | |
804 | int flags; | 811 | int flags; | |
805 | 812 | |||
806 | if (call->ktr_argsize < 2) | 813 | if (call->ktr_argsize < 2) | |
807 | return NULL; | 814 | return NULL; | |
808 | flags = (int)args[1]; | 815 | flags = (int)args[1]; | |
809 | 816 | |||
810 | if ((flags & O_RDWR) == O_RDWR) | 817 | if ((flags & O_RDWR) == O_RDWR) | |
811 | return syscall_enter(F, key, call, 1, &show_open_readwrite); | 818 | return syscall_enter(key, call, 1, &show_open_readwrite); | |
812 | else if ((flags & O_WRONLY) == O_WRONLY) | 819 | else if ((flags & O_WRONLY) == O_WRONLY) | |
813 | return syscall_enter(F, key, call, 1, &show_open_write); | 820 | return syscall_enter(key, call, 1, &show_open_write); | |
814 | else if ((flags & O_RDONLY) == O_RDONLY) | 821 | else if ((flags & O_RDONLY) == O_RDONLY) | |
815 | return syscall_enter(F, key, call, 1, &show_open_read); | 822 | return syscall_enter(key, call, 1, &show_open_read); | |
816 | else | 823 | else | |
817 | return NULL; /* XXX Do we care if no read or write? */ | 824 | return NULL; /* XXX Do we care if no read or write? */ | |
818 | } | 825 | } | |
819 | 826 | |||
827 | /*ARGSUSED*/ | |||
820 | static struct filemon_state * | 828 | static struct filemon_state * | |
821 | filemon_sys_openat(struct filemon *F, const struct filemon_key *key, | 829 | filemon_sys_openat(struct filemon *F, const struct filemon_key *key, | |
822 | const struct ktr_syscall *call) | 830 | const struct ktr_syscall *call) | |
823 | { | 831 | { | |
824 | const register_t *args = (const void *)&call[1]; | 832 | const register_t *args = (const void *)&call[1]; | |
825 | int flags, fd; | 833 | int flags, fd; | |
826 | 834 | |||
827 | if (call->ktr_argsize < 3) | 835 | if (call->ktr_argsize < 3) | |
828 | return NULL; | 836 | return NULL; | |
829 | fd = (int)args[0]; | 837 | fd = (int)args[0]; | |
830 | flags = (int)args[2]; | 838 | flags = (int)args[2]; | |
831 | 839 | |||
832 | if (fd == AT_CWD) { | 840 | if (fd == AT_CWD) { | |
833 | if ((flags & O_RDWR) == O_RDWR) | 841 | if ((flags & O_RDWR) == O_RDWR) | |
834 | return syscall_enter(F, key, call, 1, | 842 | return syscall_enter(key, call, 1, | |
835 | &show_open_readwrite); | 843 | &show_open_readwrite); | |
836 | else if ((flags & O_WRONLY) == O_WRONLY) | 844 | else if ((flags & O_WRONLY) == O_WRONLY) | |
837 | return syscall_enter(F, key, call, 1, | 845 | return syscall_enter(key, call, 1, &show_open_write); | |
838 | &show_open_write); | |||
839 | else if ((flags & O_RDONLY) == O_RDONLY) | 846 | else if ((flags & O_RDONLY) == O_RDONLY) | |
840 | return syscall_enter(F, key, call, 1, &show_open_read); | 847 | return syscall_enter(key, call, 1, &show_open_read); | |
841 | else | 848 | else | |
842 | return NULL; | 849 | return NULL; | |
843 | } else { | 850 | } else { | |
844 | if ((flags & O_RDWR) == O_RDWR) | 851 | if ((flags & O_RDWR) == O_RDWR) | |
845 | return syscall_enter(F, key, call, 1, | 852 | return syscall_enter(key, call, 1, | |
846 | &show_openat_readwrite); | 853 | &show_openat_readwrite); | |
847 | else if ((flags & O_WRONLY) == O_WRONLY) | 854 | else if ((flags & O_WRONLY) == O_WRONLY) | |
848 | return syscall_enter(F, key, call, 1, | 855 | return syscall_enter(key, call, 1, &show_openat_write); | |
849 | &show_openat_write); | |||
850 | else if ((flags & O_RDONLY) == O_RDONLY) | 856 | else if ((flags & O_RDONLY) == O_RDONLY) | |
851 | return syscall_enter(F, key, call, 1, | 857 | return syscall_enter(key, call, 1, &show_openat_read); | |
852 | &show_openat_read); | |||
853 | else | 858 | else | |
854 | return NULL; | 859 | return NULL; | |
855 | } | 860 | } | |
856 | } | 861 | } | |
857 | 862 | |||
863 | /*ARGSUSED*/ | |||
858 | static struct filemon_state * | 864 | static struct filemon_state * | |
859 | filemon_sys_symlink(struct filemon *F, const struct filemon_key *key, | 865 | filemon_sys_symlink(struct filemon *F, const struct filemon_key *key, | |
860 | const struct ktr_syscall *call) | 866 | const struct ktr_syscall *call) | |
861 | { | 867 | { | |
862 | return syscall_enter(F, key, call, 2, &show_symlink); | 868 | return syscall_enter(key, call, 2, &show_symlink); | |
863 | } | 869 | } | |
864 | 870 | |||
871 | /*ARGSUSED*/ | |||
865 | static struct filemon_state * | 872 | static struct filemon_state * | |
866 | filemon_sys_unlink(struct filemon *F, const struct filemon_key *key, | 873 | filemon_sys_unlink(struct filemon *F, const struct filemon_key *key, | |
867 | const struct ktr_syscall *call) | 874 | const struct ktr_syscall *call) | |
868 | { | 875 | { | |
869 | return syscall_enter(F, key, call, 1, &show_unlink); | 876 | return syscall_enter(key, call, 1, &show_unlink); | |
870 | } | 877 | } | |
871 | 878 | |||
879 | /*ARGSUSED*/ | |||
872 | static struct filemon_state * | 880 | static struct filemon_state * | |
873 | filemon_sys_rename(struct filemon *F, const struct filemon_key *key, | 881 | filemon_sys_rename(struct filemon *F, const struct filemon_key *key, | |
874 | const struct ktr_syscall *call) | 882 | const struct ktr_syscall *call) | |
875 | { | 883 | { | |
876 | return syscall_enter(F, key, call, 2, &show_rename); | 884 | return syscall_enter(key, call, 2, &show_rename); | |
877 | } | 885 | } |