]> git.donarmstrong.com Git - unscd.git/commitdiff
New upstream version 0.54 upstream
authorDon Armstrong <don@donarmstrong.com>
Wed, 25 Nov 2020 18:43:31 +0000 (10:43 -0800)
committerDon Armstrong <don@donarmstrong.com>
Wed, 25 Nov 2020 18:43:31 +0000 (10:43 -0800)
nscd.c

diff --git a/nscd.c b/nscd.c
index 35502d7bedb175cae7bf863206f75c2594273382..c4e4ecba4b48a217a79e0eeb54e9f439a47cfb95 100644 (file)
--- 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);