From ca2d0b980c79b1c852582b918ed6e388653e0066 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 6 May 2024 00:35:55 -0500 Subject: [PATCH] Dropped LFSR_CAT_CAT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With LFSR_CAT_DATAS for explicit arrays of datas, and this biggest use of concatenated data being a rather explicit construction in lfsr_file_carve, I don't think we really need LFSR_CAT_CAT. The only non-hacky use was to define LFSR_CAT_NAME. But we know names always use exactly 2 datas, so this might as well use LFSR_CAT_DATAS. I am going to use this soapbox to complain a bit about compound struct literals. Why do we need an array declaration to elevate temporary structs to automatic storage duration? I wish you could init a compound literal with the struct itself... ✗ &f() ✓ &(uint32_t){f()} ✓ (uint32_t[]){f()} ✗ &f() ✗ &(lfsr_data_t){f()} :( ✓ (lfsr_data_t[]){f()} Some hacky compound array literals were needed to replace the hacky LFSR_CAT_CATs in lfsr_file_carve for this reason, but I guess it's a hack for a hack so... Code unchanged: code stack before: 33728 2776 after: 33728 (+0.0%) 2776 (+0.0%) --- lfs.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lfs.c b/lfs.c index 80f6dc90..e9c651b0 100644 --- a/lfs.c +++ b/lfs.c @@ -1446,11 +1446,6 @@ typedef struct lfsr_cat { #define LFSR_CAT_DATAS(_datas, _count) \ lfsr_cat_fromdatas(_datas, _count) -#define LFSR_CAT_CAT(...) \ - lfsr_cat_fromdatas( \ - (const lfsr_data_t[]){__VA_ARGS__}, \ - sizeof((const lfsr_data_t[]){__VA_ARGS__}) / sizeof(lfsr_data_t)) - // cat helpers static inline bool lfsr_cat_isbuf(lfsr_cat_t cat) { return !(cat.u.size & LFSR_CAT_ISCAT); @@ -1516,9 +1511,11 @@ static inline lfsr_cat_t lfsr_cat_fromlleb128(uint32_t word, } #define LFSR_CAT_NAME(_did, _name, _name_size) \ - LFSR_CAT_CAT( \ - lfsr_cat_data(LFSR_CAT_LEB128(_did)), \ - LFSR_DATA_BUF(_name, _name_size)) + LFSR_CAT_DATAS( \ + ((const lfsr_data_t[2]){ \ + lfsr_cat_data(LFSR_CAT_LEB128(_did)), \ + LFSR_DATA_BUF(_name, _name_size)}), \ + 2) // cat <-> bd interactions // @@ -10393,9 +10390,9 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, LFSR_ATTR( LFSR_TAG_GROW | LFSR_TAG_SUB | LFSR_TAG_DATA, -(weight_ - lfs->cfg->fragment_size), - LFSR_CAT_CAT( + LFSR_CAT_DATA((lfsr_data_t[]){ lfsr_data_truncate(left_slice_, - lfs->cfg->fragment_size))), + lfs->cfg->fragment_size)})), LFSR_ATTR( LFSR_TAG_BLOCK, +(weight_ - lfs->cfg->fragment_size), LFSR_CAT_BPTR(&bptr_)))); @@ -10426,9 +10423,9 @@ static int lfsr_file_carve(lfs_t *lfs, lfsr_file_t *file, LFSR_ATTR( LFSR_TAG_DATA, +(weight_ - lfsr_data_size(bptr_.data)), - LFSR_CAT_CAT( + LFSR_CAT_DATA((lfsr_data_t[]){ lfsr_data_fruncate(right_slice_, - lfs->cfg->fragment_size))))); + lfs->cfg->fragment_size)})))); if (err) { return err; }