This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=785a3f36a6748fbe8c6f9ecbf5e1db5c1e901bac

commit 785a3f36a6748fbe8c6f9ecbf5e1db5c1e901bac
Author: Guillem Jover <[email protected]>
AuthorDate: Mon Jan 9 01:39:52 2023 +0100

    libdpkg: Switch dpkg_lzma_strerror() to use struct io_lzma
    
    Instead of passing the dpkg_stream_action enum, pass the io_lzma struct,
    so that we can use other members if needed.
---
 lib/dpkg/compress.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c
index e052d0bd8..bb1bf2412 100644
--- a/lib/dpkg/compress.c
+++ b/lib/dpkg/compress.c
@@ -483,9 +483,22 @@ enum dpkg_stream_status {
        DPKG_STREAM_FILTER      = DPKG_STREAM_COMPRESS | DPKG_STREAM_DECOMPRESS,
 };
 
+struct io_lzma {
+       const char *desc;
+
+       struct compress_params *params;
+
+       enum dpkg_stream_status status;
+       lzma_action action;
+
+       void (*init)(struct io_lzma *io, lzma_stream *s);
+       int (*code)(struct io_lzma *io, lzma_stream *s);
+       void (*done)(struct io_lzma *io, lzma_stream *s);
+};
+
 /* XXX: liblzma does not expose error messages. */
 static const char *
-dpkg_lzma_strerror(lzma_ret code, enum dpkg_stream_status status)
+dpkg_lzma_strerror(struct io_lzma *io, lzma_ret code)
 {
        const char *const impossible = _("internal error (bug)");
 
@@ -493,29 +506,29 @@ dpkg_lzma_strerror(lzma_ret code, enum dpkg_stream_status 
status)
        case LZMA_MEM_ERROR:
                return strerror(ENOMEM);
        case LZMA_MEMLIMIT_ERROR:
-               if (status & DPKG_STREAM_RUN)
+               if (io->status & DPKG_STREAM_RUN)
                        return _("memory usage limit reached");
                return impossible;
        case LZMA_OPTIONS_ERROR:
-               if (status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
+               if (io->status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
                        return _("unsupported compression preset");
-               if (status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
+               if (io->status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
                        return _("unsupported options in file header");
                return impossible;
        case LZMA_DATA_ERROR:
-               if (status & DPKG_STREAM_RUN)
+               if (io->status & DPKG_STREAM_RUN)
                        return _("compressed data is corrupt");
                return impossible;
        case LZMA_BUF_ERROR:
-               if (status & DPKG_STREAM_RUN)
+               if (io->status & DPKG_STREAM_RUN)
                        return _("unexpected end of input");
                return impossible;
        case LZMA_FORMAT_ERROR:
-               if (status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
+               if (io->status == (DPKG_STREAM_RUN | DPKG_STREAM_DECOMPRESS))
                        return _("file format not recognized");
                return impossible;
        case LZMA_UNSUPPORTED_CHECK:
-               if (status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
+               if (io->status == (DPKG_STREAM_INIT | DPKG_STREAM_COMPRESS))
                        return _("unsupported type of integrity check");
                return impossible;
        default:
@@ -523,18 +536,6 @@ dpkg_lzma_strerror(lzma_ret code, enum dpkg_stream_status 
status)
        }
 }
 
-struct io_lzma {
-       const char *desc;
-
-       struct compress_params *params;
-       enum dpkg_stream_status status;
-       lzma_action action;
-
-       void (*init)(struct io_lzma *io, lzma_stream *s);
-       int (*code)(struct io_lzma *io, lzma_stream *s);
-       void (*done)(struct io_lzma *io, lzma_stream *s);
-};
-
 static void
 filter_lzma(struct io_lzma *io, int fd_in, int fd_out)
 {
@@ -592,7 +593,7 @@ static void DPKG_ATTR_NORET
 filter_lzma_error(struct io_lzma *io, lzma_ret ret)
 {
        ohshit(_("%s: lzma error: %s"), io->desc,
-              dpkg_lzma_strerror(ret, io->status));
+              dpkg_lzma_strerror(io, ret));
 }
 
 #ifdef HAVE_LZMA_MT_ENCODER

-- 
Dpkg.Org's dpkg

Reply via email to