This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 0d5eec6f9ba9b31f1f9de083187f0e6e29b3327a
Author: HouLei <[email protected]>
AuthorDate: Mon Dec 5 18:09:19 2022 +0800

    fix compiler warning caused by gpfdist compression external table (#14599)
    
    Eliminate compiler warnings caused by PR 
https://github.com/greenplum-db/gpdb/pull/14144. The PR is about the 
compression transmission of the gpfdist external table.
---
 src/backend/access/external/url_curl.c | 11 ++++++-----
 src/bin/gpfdist/gpfdist.c              | 15 ++++++++-------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/backend/access/external/url_curl.c 
b/src/backend/access/external/url_curl.c
index 3ff585111b..bd86d8af8d 100644
--- a/src/backend/access/external/url_curl.c
+++ b/src/backend/access/external/url_curl.c
@@ -160,7 +160,9 @@ static char curl_Error_Buffer[CURL_ERROR_SIZE];
 static void gp_proto0_write_done(URL_CURL_FILE *file);
 static void extract_http_domain(char* i_path, char* o_domain, int dlen);
 static char * make_url(const char *url, bool is_ipv6);
-
+#ifdef USE_ZSTD
+int decompress_zstd_data(ZSTD_DCtx* ctx, ZSTD_inBuffer* bin, ZSTD_outBuffer* 
bout);
+#endif
 /* we use a global one for convenience */
 static CURLM *multi_handle = 0;
 
@@ -1578,7 +1580,6 @@ gp_proto1_read(char *buf, int bufsz, URL_CURL_FILE *file, 
CopyFromState pstate,
 {
        char type;
        int  n = 0, len = 0;
-       int obufsz = bufsz;
 
        /*
         * Loop through and get all types of messages, until we get actual data,
@@ -1746,8 +1747,8 @@ gp_proto1_read(char *buf, int bufsz, URL_CURL_FILE *file, 
CopyFromState pstate,
                if (file->lastsize > left_bytes || file->block.datalen == len)
                {
 #ifdef USE_ZSTD
-                       bufsz = ZSTD_DStreamInSize() - left_bytes;
-                       fill_buffer(file, bufsz);
+                       int wantsz = ZSTD_DStreamInSize() - left_bytes;
+                       fill_buffer(file, wantsz);
 #endif
                }
        } 
@@ -1794,7 +1795,7 @@ gp_proto1_read(char *buf, int bufsz, URL_CURL_FILE *file, 
CopyFromState pstate,
                do
                {
                        ZSTD_inBuffer bin = {file->in.ptr + file->in.bot, 
file->lastsize, 0};
-                       ZSTD_outBuffer bout = {buf, obufsz, 0};
+                       ZSTD_outBuffer bout = {buf, bufsz, 0};
                        ret = decompress_zstd_data(file->curl->zstd_dctx, &bin, 
&bout);
                        n = bout.pos; 
                        file->in.bot += bin.pos;
diff --git a/src/bin/gpfdist/gpfdist.c b/src/bin/gpfdist/gpfdist.c
index 7037dda3cc..586306281e 100644
--- a/src/bin/gpfdist/gpfdist.c
+++ b/src/bin/gpfdist/gpfdist.c
@@ -102,8 +102,9 @@ struct block_t
 
 static long REQUEST_SEQ = 0;           /*  sequence number for request */
 static long SESSION_SEQ = 0;           /*  sequence number for session */
+#ifdef USE_ZSTD
 static long OUT_BUFFER_SIZE = 0;       /* zstd out buffer size */
-
+#endif
 static bool base16_decode(char* data);
 
 #ifdef USE_SSL
@@ -383,7 +384,7 @@ static int request_validate(request_t *r);
 static int request_set_path(request_t *r, const char* d, char* p, char* pp, 
char* path);
 static int request_path_validate(request_t *r, const char* path);
 #ifdef USE_ZSTD
-static int compress_zstd(request_t *r, block_t *blk, int buflen);
+static int compress_zstd(const request_t *r, block_t *blk, int buflen);
 #endif
 static int request_parse_gp_headers(request_t *r, int opt_g);
 static void free_session_cb(int fd, short event, void* arg);
@@ -4673,7 +4674,7 @@ static void delay_watchdog_timer()
  * It is for compress data in buffer. Return is the length of data after 
compression.
  */
 
-static int compress_zstd(request_t *r, block_t *blk, int buflen)
+static int compress_zstd(const request_t *r, block_t *blk, int buflen)
 {
        char *buf = blk->data;
        int offset = 0;
@@ -4682,7 +4683,7 @@ static int compress_zstd(request_t *r, block_t *blk, int 
buflen)
        if (!r->zstd_cctx)
        {
                snprintf(r->zstd_error, r->zstd_err_len, "Creating compression 
context failed, out of memory.");
-               gprintln(NULL, r->zstd_error);
+               gprintln(NULL, "%s", r->zstd_error);
                return -1;
        }
 
@@ -4690,7 +4691,7 @@ static int compress_zstd(request_t *r, block_t *blk, int 
buflen)
        if (ZSTD_isError(init_result)) 
        {
                snprintf(r->zstd_error, r->zstd_err_len, "Creating compression 
context initialization failed, error is %s.", ZSTD_getErrorName(init_result));
-               gprintln(NULL, r->zstd_error);
+               gprintln(NULL, "%s", r->zstd_error);
                return -1;
        }
 
@@ -4705,7 +4706,7 @@ static int compress_zstd(request_t *r, block_t *blk, int 
buflen)
                        if (ZSTD_isError(res))
                        {
                                snprintf(r->zstd_error, r->zstd_err_len, 
"Compression failed, error is %s.", ZSTD_getErrorName(res));
-                               gprintln(NULL, r->zstd_error);
+                               gprintln(NULL, "%s", r->zstd_error);
                                return -1;
                        }
                        offset += bout.pos;
@@ -4719,7 +4720,7 @@ static int compress_zstd(request_t *r, block_t *blk, int 
buflen)
        if (remainingToFlush)
        {
                snprintf(r->zstd_error, r->zstd_err_len, "Compression failed, 
error is not fully flushed.");
-               gprintln(NULL, r->zstd_error);
+               gprintln(NULL, "%s", r->zstd_error);
                return -1;
        }
        offset += output.pos;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to