Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make: mark several functions whose result must ...



details:   https://anonhg.NetBSD.org/src/rev/08d17d3d7093
branches:  trunk
changeset: 1027674:08d17d3d7093
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 15 09:53:41 2021 +0000

description:
make: mark several functions whose result must be used

Suggested by sjg, to catch more bugs like the memory leak in cond.c
1.303 from 2021-12-13.

No binary change.

diffstat:

 usr.bin/make/dir.h         |  12 ++++----
 usr.bin/make/hash.h        |  16 ++++++-----
 usr.bin/make/job.h         |  13 +++++----
 usr.bin/make/lst.h         |  12 ++++----
 usr.bin/make/make.h        |  54 +++++++++++++++++++-------------------
 usr.bin/make/make_malloc.h |  12 ++++----
 usr.bin/make/meta.h        |   8 ++--
 usr.bin/make/metachar.h    |   6 ++--
 usr.bin/make/nonints.h     |  64 +++++++++++++++++++++++-----------------------
 9 files changed, 100 insertions(+), 97 deletions(-)

diffs (truncated from 551 to 300 lines):

diff -r 24bec8d6d808 -r 08d17d3d7093 usr.bin/make/dir.h
--- a/usr.bin/make/dir.h        Wed Dec 15 09:52:44 2021 +0000
+++ b/usr.bin/make/dir.h        Wed Dec 15 09:53:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dir.h,v 1.44 2021/04/03 11:08:40 rillig Exp $  */
+/*     $NetBSD: dir.h,v 1.45 2021/12/15 09:53:41 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -82,18 +82,18 @@
 void Dir_InitDot(void);
 void Dir_End(void);
 void Dir_SetPATH(void);
-bool Dir_HasWildcards(const char *);
+bool Dir_HasWildcards(const char *) MAKE_ATTR_USE;
 void SearchPath_Expand(SearchPath *, const char *, StringList *);
-char *Dir_FindFile(const char *, SearchPath *);
-char *Dir_FindHereOrAbove(const char *, const char *);
+char *Dir_FindFile(const char *, SearchPath *) MAKE_ATTR_USE;
+char *Dir_FindHereOrAbove(const char *, const char *) MAKE_ATTR_USE;
 void Dir_UpdateMTime(GNode *, bool);
 CachedDir *SearchPath_Add(SearchPath *, const char *);
-char *SearchPath_ToFlags(SearchPath *, const char *);
+char *SearchPath_ToFlags(SearchPath *, const char *) MAKE_ATTR_USE;
 void SearchPath_Clear(SearchPath *);
 void SearchPath_AddAll(SearchPath *, SearchPath *);
 void Dir_PrintDirectories(void);
 void SearchPath_Print(const SearchPath *);
-SearchPath *Dir_CopyDirSearchPath(void);
+SearchPath *Dir_CopyDirSearchPath(void) MAKE_ATTR_USE;
 
 /* Stripped-down variant of struct stat. */
 struct cached_stat {
diff -r 24bec8d6d808 -r 08d17d3d7093 usr.bin/make/hash.h
--- a/usr.bin/make/hash.h       Wed Dec 15 09:52:44 2021 +0000
+++ b/usr.bin/make/hash.h       Wed Dec 15 09:53:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.h,v 1.41 2021/12/07 21:58:01 rillig Exp $ */
+/*     $NetBSD: hash.h,v 1.42 2021/12/15 09:53:41 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -108,7 +108,7 @@
        HashTable tbl;
 } HashSet;
 
-MAKE_INLINE void *
+MAKE_INLINE void * MAKE_ATTR_USE
 HashEntry_Get(HashEntry *h)
 {
        return h->value;
@@ -131,11 +131,13 @@
 
 void HashTable_Init(HashTable *);
 void HashTable_Done(HashTable *);
-HashEntry *HashTable_FindEntry(HashTable *, const char *);
-void *HashTable_FindValue(HashTable *, const char *);
-unsigned int Hash_Substring(Substring);
-void *HashTable_FindValueBySubstringHash(HashTable *, Substring, unsigned int);
+HashEntry *HashTable_FindEntry(HashTable *, const char *) MAKE_ATTR_USE;
+void *HashTable_FindValue(HashTable *, const char *) MAKE_ATTR_USE;
+unsigned int Hash_Substring(Substring) MAKE_ATTR_USE;
+void *HashTable_FindValueBySubstringHash(HashTable *, Substring, unsigned int)
+    MAKE_ATTR_USE;
 HashEntry *HashTable_CreateEntry(HashTable *, const char *, bool *);
+/* TODO: change return type to void */
 HashEntry *HashTable_Set(HashTable *, const char *, void *);
 void HashTable_DeleteEntry(HashTable *, HashEntry *);
 void HashTable_DebugStats(HashTable *, const char *);
@@ -164,7 +166,7 @@
        return isNew;
 }
 
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 HashSet_Contains(HashSet *set, const char *key)
 {
        return HashTable_FindEntry(&set->tbl, key) != NULL;
diff -r 24bec8d6d808 -r 08d17d3d7093 usr.bin/make/job.h
--- a/usr.bin/make/job.h        Wed Dec 15 09:52:44 2021 +0000
+++ b/usr.bin/make/job.h        Wed Dec 15 09:53:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.h,v 1.73 2021/04/03 11:08:40 rillig Exp $  */
+/*     $NetBSD: job.h,v 1.74 2021/12/15 09:53:41 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -187,24 +187,25 @@
 extern int jobTokensRunning;   /* tokens currently "out" */
 
 void Shell_Init(void);
-const char *Shell_GetNewline(void);
+const char *Shell_GetNewline(void) MAKE_ATTR_USE;
 void Job_Touch(GNode *, bool);
-bool Job_CheckCommands(GNode *, void (*abortProc)(const char *, ...));
+bool Job_CheckCommands(GNode *, void (*abortProc)(const char *, ...))
+    MAKE_ATTR_USE;
 void Job_CatchChildren(void);
 void Job_CatchOutput(void);
 void Job_Make(GNode *);
 void Job_Init(void);
-bool Job_ParseShell(char *);
+bool Job_ParseShell(char *) MAKE_ATTR_USE;
 int Job_Finish(void);
 void Job_End(void);
 void Job_Wait(void);
 void Job_AbortAll(void);
 void Job_TokenReturn(void);
-bool Job_TokenWithdraw(void);
+bool Job_TokenWithdraw(void) MAKE_ATTR_USE;
 void Job_ServerStart(int, int, int);
 void Job_SetPrefix(void);
 bool Job_RunTarget(const char *, const char *);
 void Job_FlagsToString(const Job *, char *, size_t);
-int Job_TempFile(const char *, char *, size_t);
+int Job_TempFile(const char *, char *, size_t) MAKE_ATTR_USE;
 
 #endif /* MAKE_JOB_H */
diff -r 24bec8d6d808 -r 08d17d3d7093 usr.bin/make/lst.h
--- a/usr.bin/make/lst.h        Wed Dec 15 09:52:44 2021 +0000
+++ b/usr.bin/make/lst.h        Wed Dec 15 09:53:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lst.h,v 1.99 2021/12/05 10:11:31 rillig Exp $  */
+/*     $NetBSD: lst.h,v 1.100 2021/12/15 09:53:41 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -104,7 +104,7 @@
 /* Create or destroy a list */
 
 /* Create a new list. */
-List *Lst_New(void);
+List *Lst_New(void) MAKE_ATTR_USE;
 /* Free the list nodes, but not the list itself. */
 void Lst_Done(List *);
 /* Free the list nodes, freeing the node data using the given function. */
@@ -124,14 +124,14 @@
 
 /* Get information about a list */
 
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 Lst_IsEmpty(List *list)
 {
        return list->first == NULL;
 }
 
 /* Find the first node that contains the given datum, or NULL. */
-ListNode *Lst_FindDatum(List *, const void *);
+ListNode *Lst_FindDatum(List *, const void *) MAKE_ATTR_USE;
 
 /* Modify a list */
 
@@ -163,7 +163,7 @@
 }
 
 /* Remove the head node of the queue and return its datum. */
-void *Lst_Dequeue(List *);
+void *Lst_Dequeue(List *) MAKE_ATTR_USE;
 
 /*
  * A vector is an ordered collection of items, allowing for fast indexed
@@ -182,7 +182,7 @@
  * Return the pointer to the given item in the vector.
  * The returned data is valid until the next modifying operation.
  */
-MAKE_INLINE void *
+MAKE_INLINE void * MAKE_ATTR_USE
 Vector_Get(Vector *v, size_t i)
 {
        unsigned char *items = v->items;
diff -r 24bec8d6d808 -r 08d17d3d7093 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Wed Dec 15 09:52:44 2021 +0000
+++ b/usr.bin/make/make.h       Wed Dec 15 09:53:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.273 2021/12/15 09:29:55 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.274 2021/12/15 09:53:41 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -689,75 +689,75 @@
 #include "nonints.h"
 
 void GNode_UpdateYoungestChild(GNode *, GNode *);
-bool GNode_IsOODate(GNode *);
+bool GNode_IsOODate(GNode *) MAKE_ATTR_USE;
 void Make_ExpandUse(GNodeList *);
-time_t Make_Recheck(GNode *);
+time_t Make_Recheck(GNode *) MAKE_ATTR_USE;
 void Make_HandleUse(GNode *, GNode *);
 void Make_Update(GNode *);
 void GNode_SetLocalVars(GNode *);
 bool Make_Run(GNodeList *);
-bool shouldDieQuietly(GNode *, int);
+bool shouldDieQuietly(GNode *, int) MAKE_ATTR_USE;
 void PrintOnError(GNode *, const char *);
 void Main_ExportMAKEFLAGS(bool);
 bool Main_SetObjdir(bool, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
-int mkTempFile(const char *, char *, size_t);
+int mkTempFile(const char *, char *, size_t) MAKE_ATTR_USE;
 int str2Lst_Append(StringList *, char *);
 void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
-bool GNode_ShouldExecute(GNode *gn);
+bool GNode_ShouldExecute(GNode *gn) MAKE_ATTR_USE;
 
 /* See if the node was seen on the left-hand side of a dependency operator. */
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 GNode_IsTarget(const GNode *gn)
 {
        return (gn->type & OP_OPMASK) != OP_NONE;
 }
 
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_Path(const GNode *gn)
 {
        return gn->path != NULL ? gn->path : gn->name;
 }
 
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 GNode_IsWaitingFor(const GNode *gn)
 {
        return gn->flags.remake && gn->made <= REQUESTED;
 }
 
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 GNode_IsReady(const GNode *gn)
 {
        return gn->made > DEFERRED;
 }
 
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 GNode_IsDone(const GNode *gn)
 {
        return gn->made >= MADE;
 }
 
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 GNode_IsError(const GNode *gn)
 {
        return gn->made == ERROR || gn->made == ABORTED;
 }
 
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarOodate(GNode *gn) { return GNode_ValueDirect(gn, OODATE); }
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarAllsrc(GNode *gn) { return GNode_ValueDirect(gn, ALLSRC); }
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarImpsrc(GNode *gn) { return GNode_ValueDirect(gn, IMPSRC); }
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarPrefix(GNode *gn) { return GNode_ValueDirect(gn, PREFIX); }
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarArchive(GNode *gn) { return GNode_ValueDirect(gn, ARCHIVE); }
-MAKE_INLINE const char *
+MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); }
 
-MAKE_INLINE void *
+MAKE_INLINE void * MAKE_ATTR_USE
 UNCONST(const void *ptr)
 {
        void *ret;
@@ -780,19 +780,19 @@
 #define KILLPG(pid, sig) killpg((pid), (sig))
 #endif
 
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; }
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 ch_isalpha(char ch) { return isalpha((unsigned char)ch) != 0; }
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; }
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; }
-MAKE_INLINE bool
+MAKE_INLINE bool MAKE_ATTR_USE
 ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; }
-MAKE_INLINE char
+MAKE_INLINE char MAKE_ATTR_USE
 ch_tolower(char ch) { return (char)tolower((unsigned char)ch); }
-MAKE_INLINE char
+MAKE_INLINE char MAKE_ATTR_USE
 ch_toupper(char ch) { return (char)toupper((unsigned char)ch); }



Home | Main Index | Thread Index | Old Index