summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/adb.c4
-rw-r--r--src/adb_comp.c4
-rw-r--r--src/adb_walk_text.c2
-rw-r--r--src/apk_defines.h1
-rw-r--r--src/app_fetch.c6
-rw-r--r--src/app_index.c2
-rw-r--r--src/app_info.c2
-rw-r--r--src/database.c8
-rw-r--r--src/io.c8
-rw-r--r--src/io_gunzip.c4
-rw-r--r--src/tar.c2
11 files changed, 21 insertions, 22 deletions
diff --git a/src/adb.c b/src/adb.c
index 277aba6..53a82cd 100644
--- a/src/adb.c
+++ b/src/adb.c
@@ -37,7 +37,7 @@ static struct adb_block *adb_block_next(struct adb_block *cur, apk_blob_t b)
}
#define adb_foreach_block(__blk, __adb) \
- for (__blk = adb_block_first(__adb); !IS_ERR_OR_NULL(__blk); __blk = adb_block_next(__blk, __adb))
+ for (__blk = adb_block_first(__adb); __blk && !IS_ERR(__blk); __blk = adb_block_next(__blk, __adb))
/* Init stuff */
int adb_free(struct adb *db)
@@ -1103,7 +1103,7 @@ int adb_trust_write_signatures(struct apk_trust *trust, struct adb *db, struct a
size_t siglen;
int r;
- if (IS_ERR_OR_NULL(trust)) return PTR_ERR(trust);
+ if (IS_ERR(trust)) return PTR_ERR(trust);
if (!vfy) {
vfy = alloca(sizeof *vfy);
diff --git a/src/adb_comp.c b/src/adb_comp.c
index 26fb50f..3baaac3 100644
--- a/src/adb_comp.c
+++ b/src/adb_comp.c
@@ -13,7 +13,7 @@ struct apk_istream *adb_decompress(struct apk_istream *is, adb_comp_t *compressi
{
adb_comp_t c = -1;
- if (IS_ERR_OR_NULL(is)) return is;
+ if (IS_ERR(is)) return is;
uint8_t *buf = apk_istream_peek(is, 4);
if (IS_ERR(buf)) return ERR_PTR(apk_istream_close_error(is, PTR_ERR(buf)));
@@ -35,7 +35,7 @@ struct apk_istream *adb_decompress(struct apk_istream *is, adb_comp_t *compressi
struct apk_ostream *adb_compress(struct apk_ostream *os, adb_comp_t compression)
{
- if (IS_ERR_OR_NULL(os)) return os;
+ if (IS_ERR(os)) return os;
switch (compression) {
case ADB_COMP_NONE:
return os;
diff --git a/src/adb_walk_text.c b/src/adb_walk_text.c
index 1b7f5cf..f1ec7ee 100644
--- a/src/adb_walk_text.c
+++ b/src/adb_walk_text.c
@@ -19,7 +19,7 @@ int adb_walk_text(struct adb_walk *d, struct apk_istream *is)
int r = 0, i, multi_line = 0, nesting = 0, new_item = 0;
uint8_t started[64] = {0};
- if (IS_ERR_OR_NULL(is)) return PTR_ERR(is);
+ if (IS_ERR(is)) return PTR_ERR(is);
if (apk_istream_get_delim(is, token, &l) != 0) goto err;
apk_blob_pull_blob_match(&l, APK_BLOB_STR("#%SCHEMA: "));
if ((r = d->ops->schema(d, apk_blob_pull_uint(&l, 16))) != 0) goto err;
diff --git a/src/apk_defines.h b/src/apk_defines.h
index 52fef0d..d98a28d 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -69,7 +69,6 @@ static inline void *ERR_PTR(long error) { return (void*) error; }
static inline void *ERR_CAST(const void *ptr) { return (void*) ptr; }
static inline int PTR_ERR(const void *ptr) { return (int)(long) ptr; }
static inline int IS_ERR(const void *ptr) { return (unsigned long)ptr >= (unsigned long)-4095; }
-static inline int IS_ERR_OR_NULL(const void *ptr) { return IS_ERR(ptr) || !ptr; }
#if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
#define __builtin_expect(x, expected_value) (x)
diff --git a/src/app_fetch.c b/src/app_fetch.c
index c54a8e0..556ec49 100644
--- a/src/app_fetch.c
+++ b/src/app_fetch.c
@@ -171,8 +171,8 @@ static int fetch_package(apk_hash_item item, void *pctx)
}
is = apk_istream_from_fd_url(urlfd, url, apk_db_url_since(db, 0));
- if (IS_ERR_OR_NULL(is)) {
- r = PTR_ERR(is) ?: -EIO;
+ if (IS_ERR(is)) {
+ r = PTR_ERR(is);
goto err;
}
@@ -219,7 +219,7 @@ static void mark_name_flags(struct apk_database *db, const char *match, struct a
.result_mask = APK_DEPMASK_ANY,
};
- if (!IS_ERR_OR_NULL(name)) {
+ if (name) {
name->auto_select_virtual = 1;
apk_deps_add(&ctx->world, &dep);
} else {
diff --git a/src/app_index.c b/src/app_index.c
index b614283..741bcf9 100644
--- a/src/app_index.c
+++ b/src/app_index.c
@@ -199,7 +199,7 @@ static int index_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *ar
os = apk_ostream_to_file(AT_FDCWD, ictx->output, 0644);
else
os = apk_ostream_to_fd(STDOUT_FILENO);
- if (IS_ERR_OR_NULL(os)) return -1;
+ if (IS_ERR(os)) return PTR_ERR(os);
memset(&fi, 0, sizeof(fi));
fi.mode = 0644 | S_IFREG;
diff --git a/src/app_info.c b/src/app_info.c
index beb32d9..509798d 100644
--- a/src/app_info.c
+++ b/src/app_info.c
@@ -132,7 +132,7 @@ static void info_who_owns(struct info_ctx *ctx, struct apk_database *db,
}
if (verbosity < 1 && deps->num != 0) {
os = apk_ostream_to_fd(STDOUT_FILENO);
- if (!IS_ERR_OR_NULL(os)) {
+ if (!IS_ERR(os)) {
apk_deps_write(db, deps, os, APK_BLOB_PTR_LEN(" ", 1));
apk_ostream_write(os, "\n", 1);
apk_ostream_close(os);
diff --git a/src/database.c b/src/database.c
index 863829d..f64d706 100644
--- a/src/database.c
+++ b/src/database.c
@@ -704,7 +704,7 @@ int apk_db_read_overlay(struct apk_database *db, struct apk_istream *is)
struct apk_installed_package *ipkg;
apk_blob_t token = APK_BLOB_STR("\n"), line, bdir, bfile;
- if (IS_ERR_OR_NULL(is)) return PTR_ERR(is);
+ if (IS_ERR(is)) return PTR_ERR(is);
pkg = apk_pkg_new();
if (!pkg) goto no_mem;
@@ -758,7 +758,7 @@ int apk_db_index_read(struct apk_database *db, struct apk_istream *is, int repo)
gid_t gid;
int field, r, lineno = 0;
- if (IS_ERR_OR_NULL(is)) return PTR_ERR(is);
+ if (IS_ERR(is)) return PTR_ERR(is);
while (apk_istream_get_delim(is, token, &l) == 0) {
lineno++;
@@ -1223,7 +1223,7 @@ static int apk_db_index_write_nr_cache(struct apk_database *db)
/* Write list of installed non-repository packages to
* cached index file */
os = apk_ostream_to_file(db->cache_fd, "installed", 0644);
- if (IS_ERR_OR_NULL(os)) return PTR_ERR(os);
+ if (IS_ERR(os)) return PTR_ERR(os);
ctx.os = os;
list_for_each_entry(ipkg, &db->installed.packages, installed_pkgs_list) {
@@ -2769,7 +2769,7 @@ static int apk_db_unpack_pkg(struct apk_database *db,
need_copy = FALSE;
is = apk_istream_from_fd_url(filefd, file, apk_db_url_since(db, 0));
- if (IS_ERR_OR_NULL(is)) {
+ if (IS_ERR(is)) {
r = PTR_ERR(is);
if (r == -ENOENT && pkg->filename == NULL)
r = -APKE_INDEX_STALE;
diff --git a/src/io.c b/src/io.c
index 218e008..a8821e4 100644
--- a/src/io.c
+++ b/src/io.c
@@ -154,7 +154,7 @@ void *apk_istream_peek(struct apk_istream *is, size_t len)
void *apk_istream_get(struct apk_istream *is, size_t len)
{
void *p = apk_istream_peek(is, len);
- if (!IS_ERR_OR_NULL(p)) is->ptr += len;
+ if (!IS_ERR(p)) is->ptr += len;
else apk_istream_error(is, PTR_ERR(p));
return p;
}
@@ -595,7 +595,7 @@ struct apk_istream *__apk_istream_from_file(int atfd, const char *file, int try_
if (try_mmap) {
struct apk_istream *is = apk_mmap_istream_from_fd(fd);
- if (!IS_ERR_OR_NULL(is)) return is;
+ if (!IS_ERR(is)) return is;
}
return apk_istream_from_fd(fd);
}
@@ -816,7 +816,7 @@ int apk_fileinfo_get(int atfd, const char *filename, unsigned int flags,
apk_digest_calc(&fi->digest, hash_alg, target, st.st_size);
} else {
struct apk_istream *is = apk_istream_from_file(atfd, filename);
- if (!IS_ERR_OR_NULL(is)) {
+ if (!IS_ERR(is)) {
struct apk_digest_ctx dctx;
apk_blob_t blob;
@@ -995,7 +995,7 @@ struct apk_ostream *apk_ostream_to_file(int atfd, const char *file, mode_t mode)
if (fd < 0) return ERR_PTR(-errno);
os = apk_ostream_to_fd(fd);
- if (IS_ERR_OR_NULL(os)) return ERR_CAST(os);
+ if (IS_ERR(os)) return ERR_CAST(os);
struct apk_fd_ostream *fos = container_of(os, struct apk_fd_ostream, os);
fos->file = file;
diff --git a/src/io_gunzip.c b/src/io_gunzip.c
index 4ad0b6c..e3ff178 100644
--- a/src/io_gunzip.c
+++ b/src/io_gunzip.c
@@ -146,7 +146,7 @@ struct apk_istream *apk_istream_zlib(struct apk_istream *is, int raw, apk_multip
{
struct apk_gzip_istream *gis;
- if (IS_ERR_OR_NULL(is)) return ERR_CAST(is);
+ if (IS_ERR(is)) return ERR_CAST(is);
gis = malloc(sizeof(*gis) + apk_io_bufsize);
if (!gis) goto err;
@@ -231,7 +231,7 @@ struct apk_ostream *apk_ostream_zlib(struct apk_ostream *output, int raw)
{
struct apk_gzip_ostream *gos;
- if (IS_ERR_OR_NULL(output)) return ERR_CAST(output);
+ if (IS_ERR(output)) return ERR_CAST(output);
gos = malloc(sizeof(struct apk_gzip_ostream));
if (gos == NULL) goto err;
diff --git a/src/tar.c b/src/tar.c
index 8343c18..e2a1d19 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -124,7 +124,7 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
apk_blob_t pax = APK_BLOB_NULL, longname = APK_BLOB_NULL;
char filename[sizeof buf.name + sizeof buf.prefix + 2];
- if (IS_ERR_OR_NULL(is)) return PTR_ERR(is) ?: -EINVAL;
+ if (IS_ERR(is)) return PTR_ERR(is);
memset(&entry, 0, sizeof(entry));
entry.name = buf.name;