[CRIU] [PATCH] bfd: Use ERR_PTR and such instead of BREADERR
Cyrill Gorcunov
gorcunov at gmail.com
Wed Oct 1 00:24:41 PDT 2014
On Wed, Oct 01, 2014 at 11:23:19AM +0400, Cyrill Gorcunov wrote:
> On Wed, Oct 01, 2014 at 11:21:48AM +0400, Cyrill Gorcunov wrote:
> > No need to invent new error codes here, simply
> > use ERR_PTR/IS_ERR_OR_NULL and such.
> >
> > Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
>
> Drop it.
Attached.
-------------- next part --------------
>From bfdd43ee4f7c392f8e5d81265362be15c1916337 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Wed, 1 Oct 2014 11:21:35 +0400
Subject: [PATCH] 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: Cyrill Gorcunov <gorcunov at openvz.org>
---
bfd.c | 3 ++-
include/bfd.h | 4 +++-
proc_parse.c | 10 +++++-----
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/bfd.c b/bfd.c
index a45eb97297a3..d7fa16c68c39 100644
--- a/bfd.c
+++ b/bfd.c
@@ -5,6 +5,7 @@
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/uio.h>
+#include <errno.h>
#include "bug.h"
#include "log.h"
@@ -200,7 +201,7 @@ again:
/* no full line in the buffer -- refill one */
if (brefill(f) < 0)
- return BREADERR;
+ return ERR_PTR(-EIO);
refilled = true;
diff --git a/include/bfd.h b/include/bfd.h
index 080045594012..f40ae5f90c12 100644
--- a/include/bfd.h
+++ b/include/bfd.h
@@ -1,5 +1,8 @@
#ifndef __CR_BFD_H__
#define __CR_BFD_H__
+
+#include "err.h"
+
struct bfd_buf;
struct xbuf {
char *mem; /* buffer */
@@ -23,7 +26,6 @@ static inline void bfd_setraw(struct bfd *b)
b->b.mem = NULL;
}
-#define BREADERR ((char *)-1)
int bfdopen(struct bfd *f);
void bclose(struct bfd *f);
char *breadline(struct bfd *f);
diff --git a/proc_parse.c b/proc_parse.c
index d63d67755249..e0772466590c 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1106,19 +1106,19 @@ static int parse_timerfd(struct bfd *f, char *str, TimerfdEntry *tfy)
goto parse_err;
str = breadline(f);
- if (str == NULL || str == BREADERR)
+ if (IS_ERR_OR_NULL(str))
goto nodata;
if (sscanf(str, "ticks: %llu", (unsigned long long *)&tfy->ticks) != 1)
goto parse_err;
str = breadline(f);
- if (str == NULL || str == BREADERR)
+ if (IS_ERR_OR_NULL(str))
goto nodata;
if (sscanf(str, "settime flags: 0%o", &tfy->settime_flags) != 1)
goto parse_err;
str = breadline(f);
- if (str == NULL || str == BREADERR)
+ if (IS_ERR_OR_NULL(str))
goto nodata;
if (sscanf(str, "it_value: (%llu, %llu)",
(unsigned long long *)&tfy->vsec,
@@ -1126,7 +1126,7 @@ static int parse_timerfd(struct bfd *f, char *str, TimerfdEntry *tfy)
goto parse_err;
str = breadline(f);
- if (str == NULL || str == BREADERR)
+ if (IS_ERR_OR_NULL(str))
goto nodata;
if (sscanf(str, "it_interval: (%llu, %llu)",
(unsigned long long *)&tfy->isec,
@@ -1166,7 +1166,7 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
str = breadline(&f);
if (!str)
break;
- if (str == BREADERR)
+ if (IS_ERR(str))
goto out;
if (fdinfo_field(str, "pos") ||
--
1.9.3
More information about the CRIU
mailing list