Commit ae96d21a authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

bfd: Use ERR_PTR and such instead of BREADERR

No need to invent new error codes here, simply
use ERR_PTR/IS_ERR_OR_NULL and such.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent aeb3f547
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <errno.h>
#include "bug.h" #include "bug.h"
#include "log.h" #include "log.h"
...@@ -200,7 +201,7 @@ again: ...@@ -200,7 +201,7 @@ again:
/* no full line in the buffer -- refill one */ /* no full line in the buffer -- refill one */
if (brefill(f) < 0) if (brefill(f) < 0)
return BREADERR; return ERR_PTR(-EIO);
refilled = true; refilled = true;
......
#ifndef __CR_BFD_H__ #ifndef __CR_BFD_H__
#define __CR_BFD_H__ #define __CR_BFD_H__
#include "err.h"
struct bfd_buf; struct bfd_buf;
struct xbuf { struct xbuf {
char *mem; /* buffer */ char *mem; /* buffer */
...@@ -23,7 +26,6 @@ static inline void bfd_setraw(struct bfd *b) ...@@ -23,7 +26,6 @@ static inline void bfd_setraw(struct bfd *b)
b->b.mem = NULL; b->b.mem = NULL;
} }
#define BREADERR ((char *)-1)
int bfdopen(struct bfd *f); int bfdopen(struct bfd *f);
void bclose(struct bfd *f); void bclose(struct bfd *f);
char *breadline(struct bfd *f); char *breadline(struct bfd *f);
......
...@@ -1106,19 +1106,19 @@ static int parse_timerfd(struct bfd *f, char *str, TimerfdEntry *tfy) ...@@ -1106,19 +1106,19 @@ static int parse_timerfd(struct bfd *f, char *str, TimerfdEntry *tfy)
goto parse_err; goto parse_err;
str = breadline(f); str = breadline(f);
if (str == NULL || str == BREADERR) if (IS_ERR_OR_NULL(str))
goto nodata; goto nodata;
if (sscanf(str, "ticks: %llu", (unsigned long long *)&tfy->ticks) != 1) if (sscanf(str, "ticks: %llu", (unsigned long long *)&tfy->ticks) != 1)
goto parse_err; goto parse_err;
str = breadline(f); str = breadline(f);
if (str == NULL || str == BREADERR) if (IS_ERR_OR_NULL(str))
goto nodata; goto nodata;
if (sscanf(str, "settime flags: 0%o", &tfy->settime_flags) != 1) if (sscanf(str, "settime flags: 0%o", &tfy->settime_flags) != 1)
goto parse_err; goto parse_err;
str = breadline(f); str = breadline(f);
if (str == NULL || str == BREADERR) if (IS_ERR_OR_NULL(str))
goto nodata; goto nodata;
if (sscanf(str, "it_value: (%llu, %llu)", if (sscanf(str, "it_value: (%llu, %llu)",
(unsigned long long *)&tfy->vsec, (unsigned long long *)&tfy->vsec,
...@@ -1126,7 +1126,7 @@ static int parse_timerfd(struct bfd *f, char *str, TimerfdEntry *tfy) ...@@ -1126,7 +1126,7 @@ static int parse_timerfd(struct bfd *f, char *str, TimerfdEntry *tfy)
goto parse_err; goto parse_err;
str = breadline(f); str = breadline(f);
if (str == NULL || str == BREADERR) if (IS_ERR_OR_NULL(str))
goto nodata; goto nodata;
if (sscanf(str, "it_interval: (%llu, %llu)", if (sscanf(str, "it_interval: (%llu, %llu)",
(unsigned long long *)&tfy->isec, (unsigned long long *)&tfy->isec,
...@@ -1166,7 +1166,7 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type, ...@@ -1166,7 +1166,7 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
str = breadline(&f); str = breadline(&f);
if (!str) if (!str)
break; break;
if (str == BREADERR) if (IS_ERR(str))
goto out; goto out;
if (fdinfo_field(str, "pos") || if (fdinfo_field(str, "pos") ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment