summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2007-02-05 20:32:18 +0100
committerTobias Klauser <tklauser@xenon.tklauser.home>2007-02-05 20:32:18 +0100
commit52d55f8b2c68a9d5c7fd207473133adc3ff73dcd (patch)
treeedf9ed903bad0cc5a70bb7f12ed19887b0d86547
parent48a2ce3c8422fb21bba45f5ad926c13624671953 (diff)
inotail.c: Some more branch prediction
-rw-r--r--inotail.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/inotail.c b/inotail.c
index f7392ca..6999a99 100644
--- a/inotail.c
+++ b/inotail.c
@@ -131,7 +131,7 @@ static off_t lines_to_offset_from_end(struct file_struct *f, unsigned long n_lin
lseek(f->fd, offset, SEEK_SET);
rc = read(f->fd, &buf, block_size);
- if (rc < 0) {
+ if (unlikely(rc < 0)) {
fprintf(stderr, "Error: Could not read from file '%s' (%s)\n", f->name, strerror(errno));
return -1;
}
@@ -166,7 +166,7 @@ static off_t lines_to_offset_from_begin(struct file_struct *f, unsigned long n_l
lseek(f->fd, offset, SEEK_SET);
rc = read(f->fd, &buf, block_size);
- if (rc < 0) {
+ if (unlikely(rc < 0)) {
fprintf(stderr, "Error: Could not read from file '%s' (%s)\n", f->name, strerror(errno));
return -1;
} else if (rc < block_size)
@@ -229,7 +229,7 @@ static int tail_file(struct file_struct *f, unsigned long n_units, char mode, ch
f->fd = STDIN_FILENO;
else {
f->fd = open(f->name, O_RDONLY);
- if (f->fd < 0) {
+ if (unlikely(f->fd < 0)) {
fprintf(stderr, "Error: Could not open file '%s' (%s)\n", f->name, strerror(errno));
return ret;
}
@@ -257,7 +257,7 @@ static int tail_file(struct file_struct *f, unsigned long n_units, char mode, ch
offset = bytes_to_offset(f, n_units);
/* We only get negative offsets on errors */
- if (offset < 0)
+ if (unlikely(offset < 0))
goto err;
if (verbose)
@@ -345,7 +345,7 @@ static int watch_files(struct file_struct *files, int n_files)
if (errno == ENOSYS) {
fprintf(stderr, "Error: Inotify is not supported by the kernel you're currently running.\n");
exit(EXIT_FAILURE);
- } else if (ifd < 0) {
+ } else if (unlikely(ifd < 0)) {
fprintf(stderr, "Error: Could not initialize Inotify (%s)\n", strerror(errno));
exit(EXIT_FAILURE);
}
@@ -368,7 +368,7 @@ static int watch_files(struct file_struct *files, int n_files)
int ev_idx = 0;
len = read(ifd, &buf, (n_files * INOTIFY_BUFLEN));
- if (len < 0) {
+ if (unlikely(len < 0)) {
fprintf(stderr, "Error: Could not read inotify events (%s)\n", strerror(errno));
exit(EXIT_FAILURE);
}