ok

Ross L Richardson(open...@rlr.id.au) on 2020.08.03 15:37:50 +1000:
> cppcheck reports that kv_inherit(), kv_log(), and print_time() are unused.
> 
> The patch below deletes them.
> 
> Ross
> --
> 
> Index: httpd.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/httpd/httpd.c,v
> retrieving revision 1.69
> diff -u -p -r1.69 httpd.c
> --- httpd.c   30 Jul 2020 21:06:19 -0000      1.69
> +++ httpd.c   3 Aug 2020 05:35:09 -0000
> @@ -1059,50 +1059,6 @@ kv_free(struct kv *kv)
>  }
>  
>  struct kv *
> -kv_inherit(struct kv *dst, struct kv *src)
> -{
> -     memset(dst, 0, sizeof(*dst));
> -     memcpy(dst, src, sizeof(*dst));
> -     TAILQ_INIT(&dst->kv_children);
> -
> -     if (src->kv_key != NULL) {
> -             if ((dst->kv_key = strdup(src->kv_key)) == NULL) {
> -                     kv_free(dst);
> -                     return (NULL);
> -             }
> -     }
> -     if (src->kv_value != NULL) {
> -             if ((dst->kv_value = strdup(src->kv_value)) == NULL) {
> -                     kv_free(dst);
> -                     return (NULL);
> -             }
> -     }
> -
> -     return (dst);
> -}
> -
> -int
> -kv_log(struct evbuffer *log, struct kv *kv)
> -{
> -     char    *msg;
> -
> -     if (log == NULL)
> -             return (0);
> -     if (asprintf(&msg, " [%s%s%s]",
> -         kv->kv_key == NULL ? "(unknown)" : kv->kv_key,
> -         kv->kv_value == NULL ? "" : ": ",
> -         kv->kv_value == NULL ? "" : kv->kv_value) == -1)
> -             return (-1);
> -     if (evbuffer_add(log, msg, strlen(msg)) == -1) {
> -             free(msg);
> -             return (-1);
> -     }
> -     free(msg);
> -
> -     return (0);
> -}
> -
> -struct kv *
>  kv_find(struct kvtree *keys, struct kv *kv)
>  {
>       struct kv       *match;
> @@ -1270,22 +1226,6 @@ print_host(struct sockaddr_storage *ss, 
>               buf[0] = '\0';
>               return (NULL);
>       }
> -     return (buf);
> -}
> -
> -const char *
> -print_time(struct timeval *a, struct timeval *b, char *buf, size_t len)
> -{
> -     struct timeval          tv;
> -     unsigned long           h, sec, min;
> -
> -     timerclear(&tv);
> -     timersub(a, b, &tv);
> -     sec = tv.tv_sec % 60;
> -     min = tv.tv_sec / 60 % 60;
> -     h = tv.tv_sec / 60 / 60;
> -
> -     snprintf(buf, len, "%.2lu:%.2lu:%.2lu", h, min, sec);
>       return (buf);
>  }
>  
> Index: httpd.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/httpd/httpd.h,v
> retrieving revision 1.148
> diff -u -p -r1.148 httpd.h
> --- httpd.h   30 Jul 2020 21:06:19 -0000      1.148
> +++ httpd.h   3 Aug 2020 05:35:09 -0000
> @@ -731,8 +731,6 @@ void               kv_delete(struct kvtree *, struct
>  struct kv    *kv_extend(struct kvtree *, struct kv *, char *);
>  void          kv_purge(struct kvtree *);
>  void          kv_free(struct kv *);
> -struct kv    *kv_inherit(struct kv *, struct kv *);
> -int           kv_log(struct evbuffer *, struct kv *);
>  struct kv    *kv_find(struct kvtree *, struct kv *);
>  int           kv_cmp(struct kv *, struct kv *);
>  struct media_type
> @@ -751,7 +749,6 @@ struct auth       *auth_add(struct serverauth 
>  struct auth  *auth_byid(struct serverauth *, uint32_t);
>  void          auth_free(struct serverauth *, struct auth *);
>  const char   *print_host(struct sockaddr_storage *, char *, size_t);
> -const char   *print_time(struct timeval *, struct timeval *, char *, size_t);
>  const char   *printb_flags(const uint32_t, const char *);
>  void          getmonotime(struct timeval *);
>  
> 

Reply via email to