Hello community,

here is the log from the commit of package eventstat for openSUSE:Factory 
checked in at 2019-12-18 14:46:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/eventstat (Old)
 and      /work/SRC/openSUSE:Factory/.eventstat.new.4691 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "eventstat"

Wed Dec 18 14:46:13 2019 rev:8 rq:757630 version:0.04.08

Changes:
--------
--- /work/SRC/openSUSE:Factory/eventstat/eventstat.changes      2019-01-21 
10:58:33.863414713 +0100
+++ /work/SRC/openSUSE:Factory/.eventstat.new.4691/eventstat.changes    
2019-12-18 14:48:42.245949202 +0100
@@ -1,0 +2,31 @@
+Tue Dec 17 19:37:05 UTC 2019 - Martin Hauke <mar...@gmx.de>
+
+- update to version 0.04.08
+  * Add UNLIKELY hinting on memory allocation failure checks
+  * check for failed allocation of comm field
+  * Add null check on failed allocation of comm field
+  * Add null check on return of ctime
+  * Don't strdup basename return but strdup base string
+  * Fix inverted null check logic on comm field
+  * Add null check on localtime return
+  * check that basename returns a non-null string
+  * fix out of memory allocation failure check
+  * eventstat: fix '\n' check on string (null ptr dereference)
+  * eventstat: use comm field for task name rather than task info
+    field
+
+-------------------------------------------------------------------
+Tue Aug 27 09:41:42 UTC 2019 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 0.04.07
+  * No functional changes
+
+-------------------------------------------------------------------
+Fri Jul 12 18:28:14 UTC 2019 - Martin Hauke <mar...@gmx.de>
+
+- Update to version 0.04.06
+  * Reduce scope of variable ticks
+  * Remove unused assignments
+  * Update copyright year
+
+-------------------------------------------------------------------

Old:
----
  eventstat-0.04.05.tar.gz

New:
----
  eventstat-0.04.08.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ eventstat.spec ++++++
--- /var/tmp/diff_new_pack.WrVAXN/_old  2019-12-18 14:48:42.569949351 +0100
+++ /var/tmp/diff_new_pack.WrVAXN/_new  2019-12-18 14:48:42.573949352 +0100
@@ -13,12 +13,12 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 Name:           eventstat
-Version:        0.04.05
+Version:        0.04.08
 Release:        0
 Summary:        Kernel event states monitoring tool
 License:        GPL-2.0-or-later

++++++ eventstat-0.04.05.tar.gz -> eventstat-0.04.08.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/eventstat-0.04.05/Makefile 
new/eventstat-0.04.08/Makefile
--- old/eventstat-0.04.05/Makefile      2018-10-24 10:51:08.000000000 +0200
+++ new/eventstat-0.04.08/Makefile      2019-12-16 12:12:12.000000000 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2011-2018 Canonical, Ltd.
+# Copyright (C) 2011-2019 Canonical, Ltd.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 #
 
-VERSION=0.04.05
+VERSION=0.04.08
 
 CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/eventstat-0.04.05/eventstat.c 
new/eventstat-0.04.08/eventstat.c
--- old/eventstat-0.04.05/eventstat.c   2018-10-24 10:51:08.000000000 +0200
+++ new/eventstat-0.04.08/eventstat.c   2019-12-16 12:12:12.000000000 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2018 Canonical
+ * Copyright (C) 2011-2019 Canonical
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -117,9 +117,8 @@
        struct timer_info *hash_next;   /* Next in hash list */
        pid_t           pid;
        uint32_t        ref_count;      /* Timer stat reference count */
-       char            *task;          /* Name of process/kernel task */
-       char            *task_mangled;  /* Modified name of process/kernel */
        char            *cmdline;       /* From /proc/$pid/cmdline */
+       char            *comm;          /* from /proc/$pid/comm */
        char            *func;          /* Kernel waiting func */
        char            *ident;         /* Unique identity */
        uint64_t        timer;          /* Timer ID */
@@ -710,7 +709,8 @@
         * list since time is assumed to be increasing
         */
        if (!found) {
-               if ((sdl = calloc(1, sizeof(*sdl))) == NULL)
+               sdl = calloc(1, sizeof(*sdl));
+               if (UNLIKELY(!sdl))
                        err_abort("Cannot allocate sample delta list\n");
                sdl->whence = whence;
 
@@ -724,7 +724,8 @@
        }
 
        /* Now append the sdi onto the list */
-       if (UNLIKELY(((sdi = calloc(1, sizeof(*sdi))) == NULL)))
+       sdi = calloc(1, sizeof(*sdi));
+       if (UNLIKELY(!sdi))
                err_abort("Cannot allocate sample delta item\n");
        sdi->delta_events = timer_stat->info->delta_events;
        sdi->time_delta = timer_stat->info->last_used -
@@ -827,8 +828,59 @@
 }
 
 /*
+ *  unknown_comm()
+ *     return an unknonw comm field replacement
+ */
+static char *unknown_comm(void)
+{
+       return strdup("<unknown>");
+}
+
+/*
+ *  get_pid_comm
+ *     get process /proc/pid/comm field info
+ */
+static char *get_pid_comm(const pid_t id, bool kernel_thread)
+{
+       char buffer[256];
+       ssize_t ret;
+       char *comm, *ptr;
+       int fd;
+
+       (void)snprintf(buffer, sizeof(buffer), "/proc/%d/comm", id);
+       if ((fd = open(buffer, O_RDONLY)) < 0)
+               return unknown_comm();
+
+       ret = read(fd, buffer, sizeof(buffer));
+       (void)close(fd);
+       if (ret <= 0)
+               return unknown_comm();
+
+       buffer[sizeof(buffer)-1] = '\0';
+       for (ptr = buffer; *ptr; ptr++) {
+               if (*ptr == '\n') {
+                       *ptr = '\0';
+                       break;
+               }
+       }
+
+       if (kernel_thread) {
+               size_t len = strlen(buffer) + 3;
+               comm = malloc(len);
+               if (UNLIKELY(!comm))
+                       return unknown_comm();
+               snprintf(comm, len, "[%s]", buffer);
+       } else {
+               comm = strdup(buffer);
+               if (!comm)
+                       return unknown_comm();
+       }
+       return comm;
+}
+
+/*
  *  get_pid_cmdline
- *     get process's /proc/pid/cmdline
+ *     get process /proc/pid/cmdline
  */
 static char *get_pid_cmdline(const pid_t id)
 {
@@ -871,8 +923,13 @@
                }
        }
 
-       if (g_opt_flags & OPT_DIRNAME_STRIP)
-               return strdup(basename(buffer));
+       if (g_opt_flags & OPT_DIRNAME_STRIP) {
+               char *base = basename(buffer);
+
+               /* Should always be true */
+               if (base)
+                       return strdup(base);
+       }
 
        return strdup(buffer);
 }
@@ -906,7 +963,7 @@
 
        sorted_timer_infos = calloc(g_timer_info_list_length,
                                sizeof(*sorted_timer_infos));
-       if (!sorted_timer_infos)
+       if (UNLIKELY(!sorted_timer_infos))
                err_abort("Cannot allocate buffer for sorting timer_infos\n");
 
        /* Just want the timers with some non-zero total */
@@ -925,7 +982,7 @@
                if (g_opt_flags & OPT_CMD)
                        task = sorted_timer_infos[i]->cmdline;
                else
-                       task = sorted_timer_infos[i]->task_mangled;
+                       task = sorted_timer_infos[i]->comm;
 
                (void)fprintf(fp, ",%s", task);
        }
@@ -948,8 +1005,12 @@
 
                count++;
                tm = localtime(&t);
-               (void)fprintf(fp, "%2.2d:%2.2d:%2.2d",
-                       tm->tm_hour, tm->tm_min, tm->tm_sec);
+               if (tm) {
+                       (void)fprintf(fp, "%2.2d:%2.2d:%2.2d",
+                               tm->tm_hour, tm->tm_min, tm->tm_sec);
+               } else {
+                       (void)fprintf(fp, "--:--:--");
+               }
 
                if (first_time < 0)
                        first_time = sdl->whence;
@@ -1083,14 +1144,11 @@
                err_abort("Cannot allocate timer info\n");
 
        info->pid = new_info->pid;
-       info->task = strdup(new_info->task);
-       info->task_mangled = strdup(new_info->task_mangled);
+       info->comm = new_info->comm ? strdup(new_info->comm) : unknown_comm();
        info->cmdline = strdup(new_info->cmdline);
        info->func = strdup(new_info->func);
        info->ident = strdup(ident);
        info->kernel_thread = new_info->kernel_thread;
-       info->total_events = new_info->total_events;
-       info->delta_events = new_info->delta_events;
        info->time_total = new_info->time_total;
        info->timer = new_info->timer;
        info->ref_count = 0;
@@ -1101,8 +1159,7 @@
        get_proc_cpu_ticks(info->pid, &info->cpu_ticks, &info->cpu_rt_prio, 
&info->cpu_nice);
        info->cpu_ticks_time = time_now;
 
-       if (UNLIKELY(info->task == NULL ||
-                    info->task_mangled == NULL ||
+       if (UNLIKELY(info->comm == NULL ||
                     info->cmdline == NULL ||
                     info->func == NULL ||
                     info->ident == NULL)) {
@@ -1127,10 +1184,8 @@
 {
        timer_info_t *info = (timer_info_t*)data;
 
-       free(info->task);
-       if (info->cmdline != info->task_mangled)
-               free(info->cmdline);
-       free(info->task_mangled);
+       free(info->comm);
+       free(info->cmdline);
        free(info->func);
        free(info->ident);
        free(info);
@@ -1245,10 +1300,10 @@
 
        if (g_opt_flags & OPT_TIMER_ID) {
                (void)snprintf(ident, sizeof(ident), "%x%s%8.8s%" PRIx64,
-                       info->pid, info->task, info->func, info->timer);
+                       info->pid, info->comm, info->func, info->timer);
        } else {
                (void)snprintf(ident, sizeof(ident), "%x%s%8.8s",
-                       info->pid, info->task, info->func);
+                       info->pid, info->comm, info->func);
        }
        return ident;
 }
@@ -1326,7 +1381,8 @@
                g_timer_stat_free_list = g_timer_stat_free_list->next;
        } else {
                /* Get one from heap */
-               if ((ts_new = malloc(sizeof(*ts_new))) == NULL)
+               ts_new = malloc(sizeof(*ts_new));
+               if (UNLIKELY(!ts_new))
                        err_abort("Out of memory allocating a timer stat\n");
        }
 
@@ -1485,10 +1541,7 @@
                            (sorted->info->delta_events != 0)) {
                                char *task = (g_opt_flags & OPT_CMD) ?
                                        sorted->info->cmdline :
-                                       sorted->info->task_mangled;
-                               if (!*task)
-                                       task = sorted->info->task_mangled;
-
+                                       sorted->info->comm;
                                j++;
                                if (g_opt_flags & OPT_CUMULATIVE)
                                        es_printf("%*" PRIu64 " ",
@@ -1507,7 +1560,6 @@
                                        double tick_time = now - 
sorted->info->cpu_ticks_time;
                                        uint32_t tasks = 
get_proc_cpu_tasks(sorted->info->pid);
                                        uint64_t cpu_ticks;
-                                       uint64_t ticks;
                                        uint16_t cpu_rt_prio;
                                        int16_t cpu_nice;
                                        double cpu;
@@ -1516,7 +1568,8 @@
                                                           &cpu_rt_prio, 
&cpu_nice);
 
                                        if (cpu_ticks && 
sorted->info->cpu_ticks) {
-                                               ticks = cpu_ticks - 
sorted->info->cpu_ticks;
+                                               uint64_t ticks = cpu_ticks - 
sorted->info->cpu_ticks;
+
                                                cpu = (100.0 * (double)ticks) / 
(tick_time * (double)clock_tick_rate);
                                        } else {
                                                cpu = 0.0;
@@ -1554,9 +1607,15 @@
                if ((g_opt_flags & OPT_SHOW_WHENCE) && !g_curses_init) {
                        time_t t = (time_t)whence;
                        char *timestr = ctime(&t);
-                       char *pos = strchr(timestr, '\n');
+                       char *pos;
+
+                       if (timestr) {
+                               pos = strchr(timestr, '\n');
+                       } else {
+                               pos = "<unknown>";
+                       }
 
-                       if (*pos)
+                       if (pos)
                                *pos = '\0';
                        es_printf("Timestamp: %s, Total Run Duration: "
                                "%.1f secs\n", timestr, time_delta);
@@ -1583,9 +1642,11 @@
        size_t size;
 
        if (UNLIKELY(g_get_events_buf == NULL)) {
-               if ((g_get_events_buf = malloc(EVENT_BUF_SIZE << 1)) == NULL)
+               g_get_events_buf = malloc(EVENT_BUF_SIZE << 1);
+               if (UNLIKELY(!g_get_events_buf)) {
                        err_abort("Cannot read %s, out of memory\n",
                                g_sys_tracing_pipe);
+               }
 
                get_events_size = (EVENT_BUF_SIZE << 1);
        }
@@ -1635,7 +1696,7 @@
 
                        get_events_size += (EVENT_BUF_SIZE << 1);
                        tmpptr = realloc(g_get_events_buf, get_events_size + 1);
-                       if (!tmpptr) {
+                       if (UNLIKELY(!tmpptr)) {
                                (void)close(fd);
                                err_abort("Cannot read %s, out of memory\n",
                                        g_sys_tracing_pipe);
@@ -1670,10 +1731,8 @@
 
        while (*tmpptr) {
                char *ptr, *eol = tmpptr;
-               char task[64];
-               char task_mangled[68];
-               char func[64];
-               char *cmdline;
+               char func[64], task[64];
+               char *cmdline, *comm;
                int mask;
                timer_info_t info;
 
@@ -1688,7 +1747,6 @@
                }
                if (strstr(tmpptr, "hrtimer_start")) {
                        (void)memset(&info, 0, sizeof(info));
-                       (void)memset(task, 0, sizeof(task));
                        (void)memset(func, 0, sizeof(func));
 
                        /*
@@ -1723,6 +1781,9 @@
                /* Processes without a command line are kernel threads */
                cmdline = get_pid_cmdline(info.pid);
                info.kernel_thread = pid_a_kernel_thread(task, info.pid);
+               comm = get_pid_comm(info.pid, info.kernel_thread);
+               if (UNLIKELY(!comm))
+                       goto free_next;
 
                /* Swapper is special, like all corner cases */
                if (UNLIKELY(strncmp(task, "swapper", 6) == 0))
@@ -1732,21 +1793,9 @@
                if (!(g_opt_flags & mask))
                        goto free_next;
 
-               if (info.kernel_thread) {
-                       char tmp[sizeof(task)];
-
-                       (void)strcpy(tmp, task);
-                       tmp[13] = '\0';
-                       (void)snprintf(task_mangled, sizeof(task_mangled),
-                               "[%s]", tmp);
-               } else {
-                       (void)strcpy(task_mangled, task);
-               }
-
                if (strncmp(task, g_app_name, app_name_len)) {
-                       info.task = task;
-                       info.cmdline = cmdline ? cmdline : task_mangled;
-                       info.task_mangled = task_mangled;
+                       info.cmdline = cmdline ? cmdline : comm;
+                       info.comm = comm;
                        info.func = func;
                        info.time_total = 0.0;
                        info.total_events = 1;
@@ -1755,6 +1804,7 @@
                }
 free_next:
                free(cmdline);
+               free(comm);
 next:
                tmpptr = eol;
        }
@@ -1920,7 +1970,8 @@
                                errno, strerror(errno));
        }
 
-       if ((timer_stats = calloc(TABLE_SIZE, sizeof(*timer_stats))) == NULL)
+       timer_stats = calloc(TABLE_SIZE, sizeof(*timer_stats));
+       if (UNLIKELY(!timer_stats))
                err_abort("Cannot allocate timer stats table\n");
 
        /* Should really catch signals and set back to zero before we die */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/eventstat-0.04.05/snap/Makefile 
new/eventstat-0.04.08/snap/Makefile
--- old/eventstat-0.04.05/snap/Makefile 2018-10-24 10:51:08.000000000 +0200
+++ new/eventstat-0.04.08/snap/Makefile 2019-12-16 12:12:12.000000000 +0100
@@ -1,18 +1,6 @@
-VERSION=$(shell git tag | tail -1 | cut -c2-)
-COMMITS=$(shell git log --oneline | wc -l)
-SHA=$(shell git log -1 --oneline | cut -d' ' -f1)
-DATE=$(shell date +'%Y%m%d')
-V=$(VERSION)-$(DATE)-$(COMMITS)-$(SHA)
-
-all: set_version
+all: 
        LC_ALL=C.UTF-8 LANG=C.UTF-8 snapcraft
 
-set_version:
-       cat snapcraft.yaml | sed 's/version: .*/version: $(V)/' > 
snapcraft-tmp.yaml
-       mv snapcraft-tmp.yaml snapcraft.yaml
-
 clean:
        rm -rf setup *.snap
        LC_ALL=C.UTF-8 LANG=C.UTF-8 snapcraft clean
-       cat snapcraft.yaml | sed 's/version: .*/version: 0/' > 
snapcraft-tmp.yaml
-       mv snapcraft-tmp.yaml snapcraft.yaml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/eventstat-0.04.05/snap/snapcraft.yaml 
new/eventstat-0.04.08/snap/snapcraft.yaml
--- old/eventstat-0.04.05/snap/snapcraft.yaml   2018-10-24 10:51:08.000000000 
+0200
+++ new/eventstat-0.04.08/snap/snapcraft.yaml   2019-12-16 12:12:12.000000000 
+0100
@@ -1,5 +1,7 @@
 name: eventstat
-version: 0.03.04-20170425-264-0910972
+version: git
+version-script: |
+    echo $(git describe --tags)
 summary: kernel event states monitoring tool
 description:  Eventstat periodically dumps out the current kernel event state. 
 It keeps track of current events and outputs the change in events on each 
output update.  The tool requires sudo to run since it needs to write to 
/proc/timer_stats to start and stop the event monitoring.
 confinement: strict


Reply via email to