Skip to content

Commit

Permalink
Remove all of the nonnull annotations. (Fixes #41)
Browse files Browse the repository at this point in the history
They are a questionable optimization that have caused problems
in the past and may cause future problems on some systems.
  • Loading branch information
besser82 committed Oct 29, 2018
1 parent a01b32a commit f67d608
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 40 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -5,6 +5,9 @@ Please send bug reports, questions and suggestions to

Version 4.3.0
* Implement the gost-yescrypt ($gy$) hashing algorithm.
* Remove all of the nonnull annotations, which are a questionable
optimization that have caused problems in the past and may cause
future problems on some systems.

Version 4.2.3
* Add bootstrap script. If building from a Git checkout instead of a
Expand Down
14 changes: 0 additions & 14 deletions configure.ac
Expand Up @@ -96,15 +96,6 @@ __END_DECLS
[ac_cv_header_sys_cdefs_begin_end_decls=yes],
[ac_cv_header_sys_cdefs_begin_end_decls=no])
])
AC_CACHE_CHECK([whether sys/cdefs.h defines __nonnull],
[ac_cv_header_sys_cdefs_nonnull], [
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/cdefs.h>
extern char *foo(char *, char *) __nonnull ((1, 2));
]])],
[ac_cv_header_sys_cdefs_nonnull=yes],
[ac_cv_header_sys_cdefs_nonnull=no])
])
AC_CACHE_CHECK([whether sys/cdefs.h defines __THROW],
[ac_cv_header_sys_cdefs_THROW], [
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
Expand All @@ -116,17 +107,12 @@ extern void foo(void) __THROW;
])],
dnl AS_IF else
[ac_cv_header_sys_cdefs_begin_end_decls=no
ac_cv_header_sys_cdefs_nonnull=no
ac_cv_header_sys_cdefs_THROW=no])

if test $ac_cv_header_sys_cdefs_begin_end_decls = yes; then
AC_DEFINE([HAVE_SYS_CDEFS_BEGIN_END_DECLS], 1,
[Define if <sys/cdefs.h> defines __BEGIN_DECLS and __END_DECLS.])
fi
if test $ac_cv_header_sys_cdefs_nonnull = yes; then
AC_DEFINE([HAVE_SYS_CDEFS_NONNULL], 1,
[Define if <sys/cdefs.h> defines __nonnull.])
fi
if test $ac_cv_header_sys_cdefs_THROW = yes; then
AC_DEFINE([HAVE_SYS_CDEFS_THROW], 1,
[Define if <sys/cdefs.h> defines __THROW.])
Expand Down
12 changes: 4 additions & 8 deletions crypt-obsolete.h
Expand Up @@ -24,20 +24,16 @@
keep providing them for binary backward compatibility. */

/* Setup DES tables according KEY. */
extern void setkey (const char *__key)
__nonnull ((1));
extern void setkey (const char *__key);

extern void setkey_r (const char *__key,
struct crypt_data *restrict __data)
__nonnull ((1, 2));
struct crypt_data *restrict __data);

/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
block in place. */
extern void encrypt (char *__block, int __edflag)
__nonnull ((1));
extern void encrypt (char *__block, int __edflag);

extern void encrypt_r (char *__block, int __edflag,
struct crypt_data *restrict __data)
__nonnull ((1, 3));
struct crypt_data *restrict __data);

#endif /* crypt-obsolete.h */
6 changes: 0 additions & 6 deletions crypt-port.h
Expand Up @@ -43,12 +43,6 @@
#define __THROW /* nothing */
#endif

/* While actually compiling the library, suppress the __nonnull tags
on the functions in crypt.h, so that internal checks for NULL are
not deleted by the compiler. */
#undef __nonnull
#define __nonnull(param) /* nothing */

/* Suppression of unused-argument warnings. */
#if defined __GNUC__ && __GNUC__ >= 3
# define ARG_UNUSED(x) x __attribute__ ((__unused__))
Expand Down
10 changes: 5 additions & 5 deletions crypt.h.in.in
Expand Up @@ -59,7 +59,7 @@
SETTING nor to any valid hashed passphrase. Otherwise, the string
will not begin with '*'. */
extern char *crypt (const char *__phrase, const char *__setting)
__THROW __nonnull ((1, 2));
__THROW;

/* These sizes are chosen to make sizeof (struct crypt_data) add up to
exactly 32768 bytes. */
Expand Down Expand Up @@ -113,7 +113,7 @@ struct crypt_data
DATA->output. Otherwise, behaves exactly the same as crypt. */
extern char *crypt_r (const char *__phrase, const char *__setting,
struct crypt_data *__restrict __data)
__THROW __nonnull ((1, 2, 3));
__THROW;

/* Another thread-safe version of crypt. Instead of writing to a
static storage area, the string returned by this function will be
Expand All @@ -125,7 +125,7 @@ __THROW __nonnull ((1, 2, 3));
still will never begin with '*'.) */
extern char *crypt_rn (const char *__phrase, const char *__setting,
void *__data, int __size)
__THROW __nonnull ((1, 2, 3));
__THROW;

/* Yet a third thread-safe version of crypt; this one works like
getline(3). *DATA must be either 0 or a pointer to memory
Expand All @@ -139,7 +139,7 @@ __THROW __nonnull ((1, 2, 3));
a special string. */
extern char *crypt_ra (const char *__phrase, const char *__setting,
void **__data, int *__size)
__THROW __nonnull ((1, 2, 3, 4));
__THROW;


/* Generate a string suitable for use as the setting when hashing a
Expand Down Expand Up @@ -176,7 +176,7 @@ __THROW;
extern char *crypt_gensalt_rn (const char *__prefix, unsigned long __count,
const char *__rbytes, int __nrbytes,
char *__output, int __output_size)
__THROW __nonnull ((5));
__THROW;

/* Another thread-safe version of crypt_gensalt; the generated setting
string is in storage allocated by malloc, and should be deallocated
Expand Down
7 changes: 0 additions & 7 deletions gen-crypt-h.awk
Expand Up @@ -10,13 +10,11 @@
BEGIN {
HAVE_SYS_CDEFS_H = 0
HAVE_SYS_CDEFS_BEGIN_END_DECLS = 0
HAVE_SYS_CDEFS_NONNULL = 0
HAVE_SYS_CDEFS_THROW = 0
}
END {
if (!HAVE_SYS_CDEFS_H &&
(HAVE_SYS_CDEFS_BEGIN_END_DECLS ||
HAVE_SYS_CDEFS_NONNULL ||
HAVE_SYS_CDEFS_THROW)) {
print "config.h is inconsistent" > "/dev/stderr"
close("/dev/stderr")
Expand All @@ -28,8 +26,6 @@ FILENAME ~ /config\.h$/ {
HAVE_SYS_CDEFS_H = 1
} else if ($0 ~ /^#define HAVE_SYS_CDEFS_BEGIN_END_DECLS 1$/) {
HAVE_SYS_CDEFS_BEGIN_END_DECLS = 1
} else if ($0 ~ /^#define HAVE_SYS_CDEFS_NONNULL 1$/) {
HAVE_SYS_CDEFS_NONNULL = 1
} else if ($0 ~ /^#define HAVE_SYS_CDEFS_THROW 1$/) {
HAVE_SYS_CDEFS_THROW = 1
}
Expand All @@ -42,9 +38,6 @@ FILENAME !~ /config\.h$/ {
if (!HAVE_SYS_CDEFS_THROW) {
print "#define __THROW /* nothing */"
}
if (!HAVE_SYS_CDEFS_NONNULL) {
print "#define __nonnull(arg) /* nothing */"
}
print ""
if (HAVE_SYS_CDEFS_BEGIN_END_DECLS) {
print "__BEGIN_DECLS"
Expand Down

0 comments on commit f67d608

Please sign in to comment.