]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
various: fix more lgtm scan warnings
authorSami Kerola <kerolasa@iki.fi>
Thu, 20 Feb 2020 20:08:00 +0000 (20:08 +0000)
committerSami Kerola <kerolasa@iki.fi>
Thu, 20 Feb 2020 20:18:46 +0000 (20:18 +0000)
The logger and rtwake time function changes continue the same fixes as
previous commit - use thread safe functions.  The libsmartcols condition
removal is possible because width must be greater than tb->termwidth that is
size_t and cannot be smaller than zero.  And remove couple FIXME's that are
old and unlikely ever to get fixed.

Reference: 3160589d86470ce7d20c81090fb7f211b3822053
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lib/mbsalign.c
libblkid/src/read.c
libsmartcols/src/calculate.c
misc-utils/logger.c
sys-utils/rtcwake.c

index 8fdab9ee90f6c1dba8ae019f1d277233af20a578..c5d28de83ab2960135639034bf7608e31f66f2cf 100644 (file)
@@ -349,9 +349,6 @@ wc_truncate (wchar_t *wc, size_t width)
   return cells;
 }
 
-/* FIXME: move this function to gnulib as it's missing on:
-   OpenBSD 3.8, IRIX 5.3, Solaris 2.5.1, mingw, BeOS  */
-
 static int
 rpl_wcswidth (const wchar_t *s, size_t n)
 {
@@ -413,8 +410,6 @@ done:
 static char*
 mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces, int padchar)
 {
-  /* FIXME: Should we pad with "figure space" (\u2007)
-     if non ascii data present?  */
   for (/* nothing */; n_spaces && (dest < dest_end); n_spaces--)
     *dest++ = padchar;
   *dest = '\0';
index 89adf11672678fe010516810948b5d236eb0647c..5772b52fe095a5dc1b0107c9198a7d26bc7e43a6 100644 (file)
@@ -276,26 +276,6 @@ static int parse_token(char **name, char **value, char **cp)
        return 1;
 }
 
-/*
- * Extract a tag of the form <NAME>value</NAME> from the line.
- */
-/*
-static int parse_xml(char **name, char **value, char **cp)
-{
-       char *end;
-
-       if (!name || !value || !cp)
-               return -BLKID_ERR_PARAM;
-
-       *name = strip_line(*cp);
-
-       if ((*name)[0] != '<' || (*name)[1] == '/')
-               return 0;
-
-       FIXME: finish this.
-}
-*/
-
 /*
  * Extract a tag from the line.
  *
@@ -312,8 +292,7 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp)
        if (!cache || !dev)
                return -BLKID_ERR_PARAM;
 
-       if ((ret = parse_token(&name, &value, cp)) <= 0 /* &&
-           (ret = parse_xml(&name, &value, cp)) <= 0 */)
+       if ((ret = parse_token(&name, &value, cp)) <= 0)
                return ret;
 
        DBG(READ, ul_debug("tag: %s=\"%s\"", name, value));
index a0c0dc4b9bf261914faf649688a4c199d4aa28a5..625fe71ea9c6a7bde3926331a60ab7fa3c6946c8 100644 (file)
@@ -362,7 +362,7 @@ int __scols_calculate(struct libscols_table *tb, struct libscols_buffer *buf)
                                continue;
 
                        /* nothing to truncate */
-                       if (cl->width == 0 || width == 0)
+                       if (cl->width == 0)
                                continue;
 
                        trunc_flag = scols_column_is_trunc(cl)
index a7736ebe93d365a7d806bb23f5c69c12bc331046..d51cd5988e06ef89377042f9d4442793992b8a50 100644 (file)
@@ -775,13 +775,13 @@ static void syslog_rfc5424_header(struct logger_ctl *const ctl)
 
        if (ctl->rfc5424_time) {
                struct timeval tv;
-               struct tm *tm;
+               struct tm tm;
 
                logger_gettimeofday(&tv, NULL);
-               if ((tm = localtime(&tv.tv_sec)) != NULL) {
+               if (localtime_r(&tv.tv_sec, &tm) != NULL) {
                        char fmt[64];
                        const size_t i = strftime(fmt, sizeof(fmt),
-                                                 "%Y-%m-%dT%H:%M:%S.%%06u%z ", tm);
+                                                 "%Y-%m-%dT%H:%M:%S.%%06u%z ", &tm);
                        /* patch TZ info to comply with RFC3339 (we left SP at end) */
                        fmt[i - 1] = fmt[i - 2];
                        fmt[i - 2] = fmt[i - 3];
index da5ec9e3b9c6a84b29053d3dee45be31c66ca39b..ec90c9cb7d96cf7715fd6b621dca34a3ae52430e 100644 (file)
@@ -199,9 +199,10 @@ static int get_basetimes(struct rtcwake_control *ctl, int fd)
                printf("\tdelta   = %ld\n", ctl->sys_time - ctl->rtc_time);
                printf("\ttzone   = %ld\n", timezone);
                printf("\ttzname  = %s\n", tzname[daylight]);
-               gmtime_r(&ctl->rtc_time, &tm);
+               gmtime_r(&ctl->sys_time, &tm);
                printf("\tsystime = %ld, (UTC) %s",
-                               (long) ctl->sys_time, asctime_r(gmtime(&ctl->sys_time), s));
+                               (long) ctl->sys_time, asctime_r(&tm, s));
+               gmtime_r(&ctl->rtc_time, &tm);
                printf("\trtctime = %ld, (UTC) %s",
                                (long) ctl->rtc_time, asctime_r(&tm, s));
        }