Skip to content

Commit

Permalink
Negative file descriptors are valid descriptors.
Browse files Browse the repository at this point in the history
Only -1 is used to report an error by open(2).
  • Loading branch information
jedisct1 committed Jul 4, 2015
1 parent 5aae3bf commit 24dfbb0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions logger.c
Expand Up @@ -77,10 +77,10 @@ logger_lograw(int priority, const char *msg)
if (priority < 0 || priority > LOG_PRIMASK)
priority = INTERNAL_NOPRI;

if (logger_fd < 0) {
if (logger_fd == -1) {
logger_reopen();
}
if (logger_fd < 0) {
if (logger_fd == -1) {
return;
}
fp = (logger_logfile == NULL) ? stdout : fopen(logger_logfile, "a");
Expand Down
4 changes: 2 additions & 2 deletions main.c
Expand Up @@ -154,7 +154,7 @@ write_to_file(const char *path, char *buf, size_t count)
{
int fd;
fd = open(path, O_WRONLY | O_CREAT, 0444);
if (fd < 0) {
if (fd == -1) {
return -1;
}
if (safe_write(fd, buf, count, 3) != count) {
Expand All @@ -168,7 +168,7 @@ read_from_file(const char *path, char *buf, size_t count)
{
int fd;
fd = open(path, O_RDONLY);
if (fd < 0) {
if (fd == -1) {
return -1;
}
if (safe_read(fd, buf, count) != count) {
Expand Down
2 changes: 1 addition & 1 deletion version.h
Expand Up @@ -2,6 +2,6 @@
#ifndef VERSION_H
#define VERSION_H

const char *the_version = "0.1.16.1.g1c25a2d";
const char *the_version = "0.1.16.2.g5aae3bf";

#endif

0 comments on commit 24dfbb0

Please sign in to comment.