fix build when WITHOUT_LZO is set
Subsystems (2)
PATCH 1/1 fix build when WITHOUT_LZO is set
Quoted 1 line
From
3019806268ef1a9a483ca2bc35dcf1365415829fMon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Tue, 10 Mar 2015 15:20:52 +0100
Subject: [PATCH] fix build when WITHOUT_LZO is set
Make mkfs.ubifs honor the WITHOUT_LZO flag, too.
Fixes this build error:
mkfs.ubifs/compr.c:27:23: lzo/lzo1x.h: No such file or directory mkfs.ubifs/compr.c: In function `lzo_compress':
mkfs.ubifs/compr.c:92: error: `lzo_uint' undeclared (first use in this function) mkfs.ubifs/compr.c:92: error: (Each undeclared identifier is reported only once mkfs.ubifs/compr.c:92: error: for each function it appears in.) mkfs.ubifs/compr.c:92: error: syntax error before "len"
mkfs.ubifs/compr.c:95: error: len' undeclared (first use in this function) mkfs.ubifs/compr.c:96: warning: implicit declaration of function lzo1x_999_compress' mkfs.ubifs/compr.c:99: error: LZO_E_OK' undeclared (first use in this function) mkfs.ubifs/compr.c: In function init_compression':
mkfs.ubifs/compr.c:201: error: `LZO1X_999_MEM_COMPRESS' undeclared (first use in this function)
--- Makefile | 2 +- mkfs.ubifs/compr.c | 15 +++++++++++++++ mkfs.ubifs/mkfs.ubifs.c | 24 ++++++++++++++++++++---- 3 files changed, 36 insertions(+), 5 deletions(-)
Makefile +1 -1
@@ -105,7 +105,7 @@ $(call _mkdep,lib/,libmtd.a) obj-mkfs.ubifs = crc16.o lpt.o compr.o devtable.o \ hashtable/hashtable.o hashtable/hashtable_itr.o LDFLAGS_mkfs.ubifs = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS) -LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid +LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a) #
mkfs.ubifs/compr.c +15 -0
@@ -24,7 +24,9 @@#include <stdio.h> #include <stdint.h> #include <string.h> +#ifndef WITHOUT_LZO #include <lzo/lzo1x.h> +#endif #include <linux/types.h> #define crc32 __zlib_crc32
@@ -85,6 +87,7 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf,return 0 ; } +#ifndef WITHOUT_LZO static int lzo_compress (void *in_buf,size_t in_len,void *out_buf,size_t *out_len) {
@@ -102,6 +105,7 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf, return 0; } +#endif static int no_compress (void *in_buf,size_t in_len,void *out_buf,size_t *out_len)
@@ -113,6 +117,7 @@ static int no_compress(void *in_buf, size_t in_len, void *out_buf,static char *zlib_buf; +#ifndef WITHOUT_LZO static int favor_lzo_compress (void *in_buf,size_t in_len,void *out_buf,size_t *out_len,int *type) {
@@ -158,6 +163,7 @@ select_zlib:memcpy (out_buf, zlib_buf, zlib_len); return 0; } +#endif int compress_data (void *in_buf,size_t in_len,void *out_buf,size_t *out_len,int type)
@@ -169,6 +175,10 @@ 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 + { +switch (type) { +#else if (c->favor_lzo) ret =favor_lzo_compress (in_buf, in_len, out_buf, out_len, &type);else {
@@ -176,6 +186,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,case MKFS_UBIFS_COMPR_LZO : ret =lzo_compress (in_buf, in_len, out_buf, out_len);break ; +#endif case MKFS_UBIFS_COMPR_ZLIB : ret =zlib_deflate (in_buf, in_len, out_buf, out_len);break ;
@@ -197,9 +208,13 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,int init_compression (void ) { +#ifdef WITHOUT_LZO + lzo_mem =NULL ; +#else lzo_mem =malloc (LZO1X_999_MEM_COMPRESS );if (!lzo_mem)return -1 ; +#endif zlib_buf =malloc (UBIFS_BLOCK_SIZE *WORST_COMPR_FACTOR );if (!zlib_buf) {
mkfs.ubifs/mkfs.ubifs.c +20 -4
@@ -483,7 +483,11 @@ static int get_options(int argc, char**argv) c->orph_lebs =1 ; c->key_hash = key_r5_hash; c->key_len =UBIFS_SK_LEN ; +#ifdef WITHOUT_LZO + c->default_compr =UBIFS_COMPR_ZLIB ; +#else c->default_compr =UBIFS_COMPR_LZO ; +#endif c->favor_percent =20 ; c->lsave_cnt =256 ; c->leb_size =-1 ;
@@ -594,21 +598,29 @@ static int get_options(int argc, char**argv)return err_msg ("bad key hash" );break ;case 'x' : -if (strcmp (optarg,"favor_lzo" ) ==0 ) - c->favor_lzo =1 ; +if (strcmp (optarg,"none" ) ==0 ) + c->default_compr =UBIFS_COMPR_NONE ;else if (strcmp (optarg,"zlib" ) ==0 ) c->default_compr =UBIFS_COMPR_ZLIB ; -else if (strcmp (optarg,"none" ) ==0 ) - c->default_compr =UBIFS_COMPR_NONE ; +#ifndef WITHOUT_LZO + else if (strcmp(optarg, "favor_lzo") == 0) + c->favor_lzo = 1; else if (strcmp(optarg, "lzo") != 0) +#else + else +#endif return err_msg ("bad compressor name" );break ;case 'X' : +#ifdef WITHOT_LZO +return err_msg ("built without LZO support" ); +#else c->favor_percent =strtol (optarg, &endp,0 );if (*endp !='\0' || endp == optarg || c->favor_percent <=0 || c->favor_percent >=100 )return err_msg ("bad favor LZO percent '%s'" , optarg); +#endif break ;case 'j' : c->max_bud_bytes =get_bytes (optarg);
@@ -1276,7 +1288,11 @@ 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 && (flags & FS_COMPR_FL)) +#ifdef WITHOUT_LZO + use_compr =UBIFS_COMPR_ZLIB ; +#else use_compr =UBIFS_COMPR_LZO ; +#endif else use_compr = c->default_compr; compr_type = compress_data(buf, bytes_read, &dn->data,
Signature · 11 lines
1.8.4.5 -- Rolf Eike Beer, emlix GmbH, http://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Bertha-von-Suttner-Str. 9, 37085 Göttingen, Germany Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 Geschäftsführung: Dr. Uwe Kracke, Ust-IdNr.: DE 205 198 055 emlix - smart embedded open source
Quoted 171 lines · Rolf Eike Beer
From
3019806268ef1a9a483ca2bc35dcf1365415829fMon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Tue, 10 Mar 2015 15:20:52 +0100
Subject: [PATCH] fix build whenWITHOUT_LZOis setMake mkfs.ubifs honor the
WITHOUT_LZOflag, too.Fixes this build error:
mkfs.ubifs/compr.c:27:23:lzo/lzo1x.h: No such file or directorymkfs.ubifs/compr.c: In function `lzo_compress':
mkfs.ubifs/compr.c:92: error: `lzo_uint' undeclared (first use in this function)mkfs.ubifs/compr.c:92: error: (Each undeclared identifier is reported only oncemkfs.ubifs/compr.c:92: error: for each function it appears in.)mkfs.ubifs/compr.c:92: error: syntax error before "len"
mkfs.ubifs/compr.c:95: error:len' undeclared (first use in this function) mkfs.ubifs/compr.c:96: warning: implicit declaration of functionlzo1x_999_compress'mkfs.ubifs/compr.c:99: error:LZO_E_OK' undeclared (first use in this function) mkfs.ubifs/compr.c: In functioninit_compression':
mkfs.ubifs/compr.c:201: error: `LZO1X_999_MEM_COMPRESS' undeclared (first use in this function)Signed-off-by Rolf Eike Beer <[email protected]>--- Makefile | 2 +- mkfs.ubifs/compr.c | 15 +++++++++++++++ mkfs.ubifs/mkfs.ubifs.c | 24 ++++++++++++++++++++---- 3 files changed, 36 insertions(+), 5 deletions(-)Makefile +1
-1@@ -105,7 +105,7 @@ $(call _mkdep,lib/,libmtd.a) obj-mkfs.ubifs = crc16.o lpt.o compr.o devtable.o \ hashtable/hashtable.o hashtable/hashtable_itr.o LDFLAGS_mkfs.ubifs = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS) -LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid +LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a) #mkfs.ubifs/compr.c +15
-0@@ -24,7 +24,9 @@#include <stdio.h> #include <stdint.h> #include <string.h> +#ifndef WITHOUT_LZO #include <lzo/lzo1x.h> +#endif #include <linux/types.h> #define crc32 __zlib_crc32@@ -85,6 +87,7 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf,return 0 ; } +#ifndef WITHOUT_LZO static int lzo_compress (void *in_buf,size_t in_len,void *out_buf,size_t *out_len) {@@ -102,6 +105,7 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf, return 0; } +#endif static int no_compress (void *in_buf,size_t in_len,void *out_buf,size_t *out_len)@@ -113,6 +117,7 @@ static int no_compress(void *in_buf, size_t in_len, void *out_buf,static char *zlib_buf; +#ifndef WITHOUT_LZO static int favor_lzo_compress (void *in_buf,size_t in_len,void *out_buf,size_t *out_len,int *type) {@@ -158,6 +163,7 @@ select_zlib:memcpy (out_buf, zlib_buf, zlib_len); return 0; } +#endif int compress_data (void *in_buf,size_t in_len,void *out_buf,size_t *out_len,int type)@@ -169,6 +175,10 @@ 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 + { +switch (type) { +#else if (c->favor_lzo) ret =favor_lzo_compress (in_buf, in_len, out_buf, out_len, &type);else {@@ -176,6 +186,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,case MKFS_UBIFS_COMPR_LZO : ret =lzo_compress (in_buf, in_len, out_buf, out_len);break ; +#endif case MKFS_UBIFS_COMPR_ZLIB : ret =zlib_deflate (in_buf, in_len, out_buf, out_len);break ;@@ -197,9 +208,13 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,int init_compression (void ) { +#ifdef WITHOUT_LZO + lzo_mem =NULL ; +#else lzo_mem =malloc (LZO1X_999_MEM_COMPRESS );if (!lzo_mem)return -1 ; +#endif zlib_buf =malloc (UBIFS_BLOCK_SIZE *WORST_COMPR_FACTOR );if (!zlib_buf) {mkfs.ubifs/mkfs.ubifs.c +16
-4@@ -483,7 +483,11 @@ static int get_options(int argc, char**argv) c->orph_lebs =1 ; c->key_hash = key_r5_hash; c->key_len =UBIFS_SK_LEN ; +#ifdef WITHOUT_LZO + c->default_compr =UBIFS_COMPR_ZLIB ; +#else c->default_compr =UBIFS_COMPR_LZO ; +#endif c->favor_percent =20 ; c->lsave_cnt =256 ; c->leb_size =-1 ;@@ -594,21 +598,29 @@ static int get_options(int argc, char**argv)return err_msg ("bad key hash" );break ;case 'x' : -if (strcmp (optarg,"favor_lzo" ) ==0 ) - c->favor_lzo =1 ; +if (strcmp (optarg,"none" ) ==0 ) + c->default_compr =UBIFS_COMPR_NONE ;else if (strcmp (optarg,"zlib" ) ==0 ) c->default_compr =UBIFS_COMPR_ZLIB ; -else if (strcmp (optarg,"none" ) ==0 ) - c->default_compr =UBIFS_COMPR_NONE ; +#ifndef WITHOUT_LZO + else if (strcmp(optarg, "favor_lzo") == 0) + c->favor_lzo = 1; else if (strcmp(optarg, "lzo") != 0) +#else + else +#endif return err_msg ("bad compressor name" );break ;case 'X' : +#ifdef WITHOT_LZO +return err_msg ("built without LZO support" ); +#else c->favor_percent =strtol (optarg, &endp,0 );if (*endp !='\0' || endp == optarg || c->favor_percent <=0 || c->favor_percent >=100 )return err_msg ("bad favor LZO percent '%s'" , optarg); +#endif break ;case 'j' : c->max_bud_bytes =get_bytes (optarg);@@ -1276,7 +1288,11 @@ static int add_file(const char *path_name, struct stat *st, ino_t inum, out_len =NODE_BUFFER_SIZE -UBIFS_DATA_NODE_SZ ;
mkfs.ubifs/mkfs.ubifs.c static int add_file(const char *path_name, struct stat *st, ino_t inum, · line 1298
Quoted 10 lines
mkfs.ubifs/mkfs.ubifs.c +4
-0if (c->default_compr ==UBIFS_COMPR_NONE && (flags & FS_COMPR_FL)) +#ifdef WITHOUT_LZO + use_compr =UBIFS_COMPR_ZLIB ; +#else use_compr =UBIFS_COMPR_LZO ; +#endif else use_compr = c->default_compr; compr_type = compress_data(buf, bytes_read, &dn->data,
Patches makes sense to me.
Maybe it would make sense to move LZO related stuff out of compr.c to reduce the amount of ifdefs.
Artem, Brian, what do you think?
Signature · 2 lines
Thanks, //richard
Quoted 20 lines · Richard Weinberger
Quoted 7 lines · Rolf Eike Beer
From
3019806268ef1a9a483ca2bc35dcf1365415829fMon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Tue, 10 Mar 2015 15:20:52 +0100
Subject: [PATCH] fix build whenWITHOUT_LZOis setMake mkfs.ubifs honor the
WITHOUT_LZOflag, too.Quoted 12 lines
Fixes this build error:
mkfs.ubifs/compr.c:27:23:lzo/lzo1x.h: No such file or directorymkfs.ubifs/compr.c: In function `lzo_compress':
mkfs.ubifs/compr.c:92: error: `lzo_uint' undeclared (first use in this function)mkfs.ubifs/compr.c:92: error: (Each undeclared identifier is reported only oncemkfs.ubifs/compr.c:92: error: for each function it appears in.)mkfs.ubifs/compr.c:92: error: syntax error before "len"
mkfs.ubifs/compr.c:95: error:len' undeclared (first use in this function) mkfs.ubifs/compr.c:96: warning: implicit declaration of functionlzo1x_999_compress'mkfs.ubifs/compr.c:99: error:LZO_E_OK' undeclared (first use in this function) mkfs.ubifs/compr.c: In functioninit_compression':
mkfs.ubifs/compr.c:201: error: `LZO1X_999_MEM_COMPRESS' undeclared (first use in this function)
Quoted 6 lines
Patches makes sense to me.
Maybe it would make sense to move LZO related stuff out of
compr.cto reduce the amount of ifdefs.Artem, Brian, what do you think?
Sorry, this patch got lost. ;-\
I've applied and pushed it now as it fixes a real problem.
Signature · 2 lines
Thanks, //richard