]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Add a message if --block-list is used outside of xz compresssion.
authorJia Tan <jiat0218@gmail.com>
Sat, 13 May 2023 11:28:23 +0000 (19:28 +0800)
committerJia Tan <jiat0218@gmail.com>
Mon, 17 Jul 2023 15:34:55 +0000 (23:34 +0800)
--block-list is only supported with compression in xz format. This avoids
silently ignoring when --block-list is unused.

src/xz/args.c

index b2eee19384e59169a2d6e04081a27bba556732f6..6ae3c96ffbfb932bf351a40000186afe7af534e2 100644 (file)
@@ -788,6 +788,17 @@ args_parse(args_info *args, int argc, char **argv)
        if (opt_mode == MODE_COMPRESS && opt_format == FORMAT_AUTO)
                opt_format = FORMAT_XZ;
 
+       // Set opt_block_list to NULL if we are not compressing to the .xz
+       // format. This option cannot be used outside of this case, and
+       // simplifies the implementation later.
+       if ((opt_mode != MODE_COMPRESS || opt_format != FORMAT_XZ)
+                       && opt_block_list != NULL) {
+               message(V_WARNING, _("--block-list is ignored unless "
+                               "compressing to the .xz format"));
+               free(opt_block_list);
+               opt_block_list = NULL;
+       }
+
        // Compression settings need to be validated (options themselves and
        // their memory usage) when compressing to any file format. It has to
        // be done also when uncompressing raw data, since for raw decoding