Bug#983290: worklog: summary prints 0.0 even when no work done
Sorry, my description of what is expected was incorrect. I think just looking at the code shows that the current code is wrong, since the first time through the loop, "seconds" is uninitialized, which is incorrect. A better set of steps to reproduce: /usr/bin/worklog ~/worklog/projects time.log Add time to a project and quit Contents of time.log: ProjectB : 1.00 seconds : finished Fri Oct 20 06:01:20 2023 -- Worklog summary begins : Fri Oct 20 06:01:16 2023 -- ProjectA : total 0.00 seconds -- Worklog summary ends : Fri Oct 20 06:01:21 2023 -- /usr/bin/worklog ~/worklog/projects time.log Quit immediately: New contents of time.log: -- Worklog summary begins : Fri Oct 20 06:01:27 2023 -- ProjectA : total 0.00 seconds -- Worklog summary ends : Fri Oct 20 06:01:28 2023 -- ProjectB isn't listed at all. What it should look like is this: Complete contents of time.log when running the aboe steps after the patch is applied: ProjectB : 1.00 seconds : finished Fri Oct 20 06:04:27 2023 -- Worklog summary begins : Fri Oct 20 06:04:24 2023 -- ProjectB : total 1.00 seconds -- Worklog summary ends : Fri Oct 20 06:04:28 2023 -- -- Worklog summary begins : Fri Oct 20 06:04:33 2023 -- ProjectB : total 1.00 seconds -- Worklog summary ends : Fri Oct 20 06:04:34 2023 --
Bug#983290: worklog: summary prints 0.0 even when no work done
Package: worklog Version: 2.1-1 Followup-For: Bug #983290 Sorry, I missed your reply. I can recreate this trivially by using an empty directory and having a valid projects file with more than one project letter in it and running worklog and then immediately exiting. It will display the first project with 0.0 seconds and that is it. I would expect it to print all of the projects with 0.0 seconds rather than just one. The bug is an incorrectly applied patch that causes "seconds" to be accessed prior to being initialized. I don't have a .deb built, so I'm not sure how to make debdiff work. I see you are using github now, so I can do a pull request there. The previously given diff just moves the assignment of seconds to the line before it is read. -- System Information: Debian Release: 11.7 APT prefers oldstable-updates APT policy: (500, 'oldstable-updates'), (500, 'oldstable-security'), (500, 'oldstable-proposed-updates'), (500, 'oldstable') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-13-amd64 (SMP w/12 CPU threads) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages worklog depends on: ii libc62.31-13+deb11u6 ii libncurses6 6.2+20201114-2+deb11u2 ii libtinfo66.2+20201114-2+deb11u2 worklog recommends no packages. worklog suggests no packages. -- no debconf information
Bug#983290: worklog: summary prints 0.0 even when no work done
Package: worklog Version: 2.1-1 Followup-For: Bug #983290 github pull request here: https://github.com/atsb/worklog/pull/1 -- System Information: Debian Release: 11.7 APT prefers oldstable-updates APT policy: (500, 'oldstable-updates'), (500, 'oldstable-security'), (500, 'oldstable-proposed-updates'), (500, 'oldstable') Architecture: amd64 (x86_64) Kernel: Linux 5.10.0-13-amd64 (SMP w/12 CPU threads) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages worklog depends on: ii libc62.31-13+deb11u6 ii libncurses6 6.2+20201114-2+deb11u2 ii libtinfo66.2+20201114-2+deb11u2 worklog recommends no packages. worklog suggests no packages. -- no debconf information
Bug#983290: worklog: summary prints 0.0 even when no work done
Hi, Could you please submit a debdiff or provide a bit more insight? I cannot reproduce this locally. Thanks.
Bug#983290: worklog: summary prints 0.0 even when no work done
Package: worklog Version: 2.1 Severity: minor Tags: patch worklog.c: In function ‘exit_handler’: worklog.c:365:7: warning: ‘seconds’ may be used uninitialized in this function [-Wmaybe-uninitialized] if(!seconds) Because seconds is unitialized, the summary always prints incorrectly, always printing out the last project even if that wasn't touched, and not printing anything else. The following patch fixes the bug. 364a365 > seconds=(double) project->time; 367d367 < seconds=(double) project->time; -- System Information: Debian Release: 10.8 APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'proposed-updates'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 4.19.0-12-amd64 (SMP w/12 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages worklog depends on: ii libc62.28-10 ii libncurses6 6.1+20181013-2+deb10u2 ii libtinfo66.1+20181013-2+deb10u2 worklog recommends no packages. worklog suggests no packages. -- no debconf information