mirror of
https://github.com/FAUSheppy/colorredstderr-mirror
synced 2025-12-12 01:48:33 +01:00
Add assert()s.
This commit is contained in:
@@ -25,6 +25,12 @@
|
||||
/* Must be loaded before the following headers. */
|
||||
#include "ldpreload.h"
|
||||
|
||||
/* Disable assert()s if not compiled with --enable-debug. */
|
||||
#ifndef DEBUG
|
||||
# define NDEBUG
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
@@ -78,6 +84,8 @@ static int force_write_to_non_tty;
|
||||
* additional call. */
|
||||
static int isatty_noinline(int fd) noinline;
|
||||
static int isatty_noinline(int fd) {
|
||||
assert(fd >= 0);
|
||||
|
||||
int saved_errno = errno;
|
||||
int result = isatty(fd);
|
||||
errno = saved_errno;
|
||||
@@ -91,6 +99,8 @@ static void dup_fd(int oldfd, int newfd) {
|
||||
debug("%3d -> %3d\t\t\t[%d]\n", oldfd, newfd, getpid());
|
||||
#endif
|
||||
|
||||
assert(oldfd >= 0 && newfd >= 0);
|
||||
|
||||
if (unlikely(!initialized)) {
|
||||
init_from_environment();
|
||||
}
|
||||
@@ -113,6 +123,8 @@ static void close_fd(int fd) {
|
||||
debug("%3d -> .\t\t\t[%d]\n", fd, getpid());
|
||||
#endif
|
||||
|
||||
assert(fd >= 0);
|
||||
|
||||
if (unlikely(!initialized)) {
|
||||
init_from_environment();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user