summaryrefslogtreecommitdiff
path: root/ubifs-utils/mkfs.ubifs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-02-28 13:50:57 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-02-15 15:07:17 +0100
commit6fcdc552ffdca93334ffe2d044745c83de0722fa (patch)
treed04cc29c4cbd576a8690cc4bdd4b374c45356166 /ubifs-utils/mkfs.ubifs
parent1be992db04fc71296a98303724635b2b6b0cd10d (diff)
Cleanup handling of optional dependencies
Don't use super pedantic parsing of the argument and work with the generated variable instead of assigning it to our own and set it to "check" if not value is assigned. Then search for a dependency if the with variable is anything other than "no" and fail if it was set to "yes". In addition, the WITHOUT_xxx defines are replaced with WITH_xxx defines. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/mkfs.ubifs')
-rw-r--r--ubifs-utils/mkfs.ubifs/compr.c22
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c16
2 files changed, 19 insertions, 19 deletions
diff --git a/ubifs-utils/mkfs.ubifs/compr.c b/ubifs-utils/mkfs.ubifs/compr.c
index 06c35ca..07f6d4a 100644
--- a/ubifs-utils/mkfs.ubifs/compr.c
+++ b/ubifs-utils/mkfs.ubifs/compr.c
@@ -24,11 +24,11 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
#include <lzo/lzo1x.h>
#endif
#include <linux/types.h>
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
#include <zstd.h>
#endif
@@ -41,7 +41,7 @@
static void *lzo_mem;
static unsigned long long errcnt = 0;
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
static struct ubifs_info *c = &info_;
#endif
@@ -92,7 +92,7 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf,
return 0;
}
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
{
@@ -112,7 +112,7 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
}
#endif
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
static ZSTD_CCtx *zctx;
static int zstd_compress(void *in_buf, size_t in_len, void *out_buf,
@@ -140,7 +140,7 @@ static int no_compress(void *in_buf, size_t in_len, void *out_buf,
static char *zlib_buf;
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
static int favor_lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len, int *type)
{
@@ -198,7 +198,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
return MKFS_UBIFS_COMPR_NONE;
}
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
{
switch (type) {
#else
@@ -213,7 +213,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
case MKFS_UBIFS_COMPR_ZLIB:
ret = zlib_deflate(in_buf, in_len, out_buf, out_len);
break;
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
case MKFS_UBIFS_COMPR_ZSTD:
ret = zstd_compress(in_buf, in_len, out_buf, out_len);
break;
@@ -236,7 +236,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
int init_compression(void)
{
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
lzo_mem = NULL;
#else
lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
@@ -248,7 +248,7 @@ int init_compression(void)
if (!zlib_buf)
goto err;
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
zctx = ZSTD_createCCtx();
if (!zctx)
goto err;
@@ -265,7 +265,7 @@ void destroy_compression(void)
{
free(zlib_buf);
free(lzo_mem);
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
ZSTD_freeCCtx(zctx);
#endif
if (errcnt)
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 8f8d40b..5d3b80c 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -26,7 +26,7 @@
#include <crc32.h>
#include "common.h"
#include <sys/types.h>
-#ifndef WITHOUT_XATTR
+#ifdef WITH_XATTR
#include <sys/xattr.h>
#endif
@@ -35,7 +35,7 @@
#include <selinux/label.h>
#endif
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
#include <zstd.h>
#endif
@@ -539,7 +539,7 @@ static void select_default_compr(void)
return;
}
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
c->default_compr = UBIFS_COMPR_ZLIB;
#else
c->default_compr = UBIFS_COMPR_LZO;
@@ -683,11 +683,11 @@ static int get_options(int argc, char**argv)
c->default_compr = UBIFS_COMPR_NONE;
else if (strcmp(optarg, "zlib") == 0)
c->default_compr = UBIFS_COMPR_ZLIB;
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
else if (strcmp(optarg, "zstd") == 0)
c->default_compr = UBIFS_COMPR_ZSTD;
#endif
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
else if (strcmp(optarg, "favor_lzo") == 0) {
c->default_compr = UBIFS_COMPR_LZO;
c->favor_lzo = 1;
@@ -699,7 +699,7 @@ static int get_options(int argc, char**argv)
return err_msg("bad compressor name");
break;
case 'X':
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
return err_msg("built without LZO support");
#else
c->favor_percent = strtol(optarg, &endp, 0);
@@ -1288,7 +1288,7 @@ out:
return ret;
}
-#ifdef WITHOUT_XATTR
+#ifndef WITH_XATTR
static inline int create_inum_attr(ino_t inum, const char *name)
{
(void)inum;
@@ -1858,7 +1858,7 @@ static int add_file(const char *path_name, struct stat *st, ino_t inum,
out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
if (c->default_compr == UBIFS_COMPR_NONE &&
!c->encrypted && (flags & FS_COMPR_FL))
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
use_compr = UBIFS_COMPR_ZLIB;
#else
use_compr = UBIFS_COMPR_LZO;