From: Don Armstrong Date: Wed, 25 Nov 2020 18:43:31 +0000 (-0800) Subject: New upstream version 0.54 X-Git-Url: https://git.donarmstrong.com/?p=unscd.git;a=commitdiff_plain;h=7b515f87070b50b5bae21f648f429b3dee7aee0e New upstream version 0.54 --- diff --git a/nscd.c b/nscd.c index 35502d7..c4e4ecb 100644 --- a/nscd.c +++ b/nscd.c @@ -146,8 +146,9 @@ vda.linux@googlemail.com * 0.51 fix a case where we forget to refcount-- the cached entry * 0.52 make free_refcounted_ureq() tolerant to pointers to NULLs * 0.53 fix INVALIDATE and SHUTDOWN requests being ignored + * 0.54 clang warning fix for "str" + OFFSET trick and variable struct field */ -#define PROGRAM_VERSION "0.53" +#define PROGRAM_VERSION "0.54" #define DEBUG_BUILD 1 @@ -270,9 +271,11 @@ static void dump(const void *ptr, int len) buf = ptr; while (len > 0) { int chunk = ((len >= 16) ? 16 : len); - fprintf(stderr, + const char *fmt = "%02x %02x %02x %02x %02x %02x %02x %02x " - "%02x %02x %02x %02x %02x %02x %02x %02x " + (16-chunk) * 5, + "%02x %02x %02x %02x %02x %02x %02x %02x "; + fmt += (16-chunk) * 5; + fprintf(stderr, fmt, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9],buf[10],buf[11],buf[12],buf[13],buf[14],buf[15] ); @@ -2442,15 +2445,14 @@ static void special_op(const char *arg) printf("sent shutdown request, exiting\n"); } else { /* invalidate */ size_t arg_len = strlen(arg) + 1; - struct { - user_req_header req; - char arg[arg_len]; - } reqdata; - reqdata.req.version = NSCD_VERSION; - reqdata.req.type = INVALIDATE; - reqdata.req.key_len = arg_len; - memcpy(reqdata.arg, arg, arg_len); - xfull_write(sock, &reqdata, arg_len + sizeof(ureq)); + char buf[sizeof(user_req_header) + arg_len]; + user_req_header *req = (void*) buf; + + req->version = NSCD_VERSION; + req->type = INVALIDATE; + req->key_len = arg_len; + memcpy(req + 1, arg, arg_len); + xfull_write(sock, req, sizeof(*req) + arg_len); printf("sent invalidate(%s) request, exiting\n", arg); } exit(0);