Commit Graph

15 Commits

Author SHA1 Message Date
rillig
0cbd5c0e4f make(1): remove unreached code from bmake_strndup
The "at most" branch was never taken since all call sites in var.c only
ever need a substring, and the target buffer is not limited.  Therefore
rename the function and make it simpler.

It's ok that bmake_strldup is defined as estrndup in case of USE_EMALLOC
since that function's implementation is compatible to the "copy
exactly", it just contains some extra null checks that will never match
since the variable values cannot (well, or should not) contain null
bytes.  Theoretically they can, but the behavior then depends on the
exact implementation and is unreliable, therefore nobody does this.
After all, Makefiles are used for text processing, not for binary data.
2020-08-20 06:35:14 +00:00
rillig
ee1eefc8ec make(1): remove unnecessary test from bmake_strndup
The passed memory is never NULL.
2020-08-12 18:47:21 +00:00
rillig
0fc5d0f74a make(1): in bmake_strndup, only scan the relevant part of the string
Just in case the given str is not really a string.

The POSIX 2018 documentation on strndup does not specify as clearly as
possible whether s has to be a string or whether raw memory is
acceptable as well.  It only indirectly calls the s parameter of strndup
a string.
2020-08-12 03:27:29 +00:00
rillig
44d841d2c5 make(1): remove redundant parentheses around return values 2020-07-03 08:02:55 +00:00
dholland
3e81c5349d nowadays function specifiers go in declaration_specifiers
(not after the declarator)
2017-04-16 20:20:24 +00:00
sjg
e47157f5d2 Do not include make_malloc.h or declare progname,
both are already done in make.h
2012-06-20 17:46:28 +00:00
joerg
b1e1b1d4c2 Replace __dead, __unused and the various printf format attributes
with versions prefixed by MAKE_ATTR_* to avoid modifying the
implementation namespace. Make sure they are available in all places
using nonints.h to fix bootstrap on Linux.
2012-06-12 19:21:50 +00:00
wiz
8e7413b140 Declare enomem __dead for clang. 2012-06-10 21:44:12 +00:00
sjg
35fdcec3af Avoid nested extern declaration warnings 2012-05-18 02:28:16 +00:00
dholland
f8d6aa2c68 Many C libraries don't set errno when malloc fails, so always use
strerror(ENOMEM).
2010-12-25 20:35:25 +00:00
dsl
b294f6c2a3 Fix sense of MAKE_NATICE test. 2009-01-24 23:19:50 +00:00
dsl
4802ea584f Add #ifndef MAKE_NATIVE around __RCSID 2009-01-24 23:07:48 +00:00
dsl
97347d2cbb Fixes to includes of make_malloc.h to that it actually builds when
USE_EMALLOC is undefined.
Fixes earlier fixes :-)
2009-01-24 14:43:28 +00:00
cegger
9fde1a673e buildfixes for OSX:
- include <sys/types> for size_t
- progname is undeclared
- include <string.h> for string functions like strlen()
- include <errno.h> for errno
2009-01-24 13:06:16 +00:00
dsl
4fb693c12c Move the bmake_malloc() functions into their own .c and .h files.
Include instead of make.h in a few places.
2009-01-24 11:59:39 +00:00