Bug 71618 - [patch] timed(8): cleanup of the usr.sbin/timed code
Summary: [patch] timed(8): cleanup of the usr.sbin/timed code
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 5.3-BETA3
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-09-12 03:40 UTC by Dan Lukes
Modified: 2022-10-17 12:39 UTC (History)
0 users

See Also:


Attachments
file.diff (702 bytes, patch)
2004-09-12 03:40 UTC, Dan Lukes
no flags Details | Diff
acksend.c.diff (216 bytes, patch)
2008-09-04 23:40 UTC, Rebecca Cran
no flags Details | Diff
correct.c.diff (435 bytes, patch)
2008-09-04 23:40 UTC, Rebecca Cran
no flags Details | Diff
globals.h.diff (378 bytes, patch)
2008-09-04 23:40 UTC, Rebecca Cran
no flags Details | Diff
master.c.diff (651 bytes, patch)
2008-09-04 23:40 UTC, Rebecca Cran
no flags Details | Diff
readmsg.c.diff (1.12 KB, patch)
2008-09-04 23:40 UTC, Rebecca Cran
no flags Details | Diff
slave.c.diff (1.78 KB, patch)
2008-09-04 23:40 UTC, Rebecca Cran
no flags Details | Diff
timed.c.diff (803 bytes, patch)
2008-09-04 23:40 UTC, Rebecca Cran
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Lukes 2004-09-12 03:40:23 UTC
	There are more than 5000 warnings issued during "make buildworld".
Some of them are false positives, but some of them are sign of true errors.

	Nobody is upset by warnings due it's amount, so some errors remain
uncorrected.

	I want to cleanup the code-base from warnings, so warnings will
become "attention mark" again.

usr.sbin/timed/timed/master.c:340: warning: no return statement in function returning non-void
usr.sbin/timed/timed/readmsg.c:501: warning: long int format, int32_t arg (arg 6)
usr.sbin/timed/timed/readmsg.c:501: warning: long int format, int32_t arg (arg 7)

How-To-Repeat: 	N/A
Comment 1 Giorgos Keramidas freebsd_committer freebsd_triage 2004-09-12 19:35:35 UTC
On 2004-09-12 04:37, Dan Lukes <dan@obluda.cz> wrote:
> usr.sbin/timed/timed/readmsg.c:501: warning: long int format, int32_t arg (arg 6)
> usr.sbin/timed/timed/readmsg.c:501: warning: long int format, int32_t arg (arg 7)

> - 		fprintf(fd, "%s %d %-6u (%ld,%ld) %-15s %s\n",
> + 		fprintf(fd, "%s %d %-6u (%d,%d) %-15s %s\n",

There's no guarantee that an int32_t value will be defined with an `int'.
This might result in unexpected truncation of the printed value.  A better
fix, IMHO, would be to change the format to %jd and then cast the value to
(intmax_t) which should avoid truncation of the value (you'll also have to
include <stdint.h> for intmax_t to be visible).

There are many other warnings in timed that are exposed if you try to build
it with an increased WARNS level.  Since you seem to like doing this sort
of work, can you try the following (and see if you can come up with fixes
for the warnings this shows)?

	# cd /usr/src/usr.sbin/timed/
	# make NO_WERROR=1 WARNS?=3

Thank you for your work so far :-)
Comment 2 Dan Lukes 2004-09-13 02:37:11 UTC
On Sun, 12 Sep 2004, Giorgos Keramidas wrote:

>> - 		fprintf(fd, "%s %d %-6u (%ld,%ld) %-15s %s\n",
>> + 		fprintf(fd, "%s %d %-6u (%d,%d) %-15s %s\n",
>
> There's no guarantee that an int32_t value will be defined with an `int'.
> This might result in unexpected truncation of the printed value.  A better

 	True. In the fact, I miss the existence of 'j' modifier and intmax_t
type.

> of work, can you try the following (and see if you can come up with fixes
> for the warnings this shows)?
>
> 	# cd /usr/src/usr.sbin/timed/
> 	# make NO_WERROR=1 WARNS?=3

 	I'm compiling with -Wall -O3.
 	It seems to be more than any WARNS=X

 	If there are some warning not corrected by attached patches, then it
mean I'm don't know how the good way to correct it.

> Thank you for your work so far :-)

 	I have a lot of spare time now only ... ;-)
 								Dan
Comment 3 Rebecca Cran freebsd_committer freebsd_triage 2008-09-04 23:40:53 UTC
The attached patches fix a lot of the warnings in usr.sbin/timed with
high WARNS levels and GCC 4.

-- 
Bruce Cran
Comment 4 Dan Lukes 2008-09-05 06:59:44 UTC
Bruce Cran napsal/wrote, On 09/05/08 00:40:
> +		       "clock correction %lld sec too large to adjust",
> +		       (long long int)adj.tv_sec);


It seems to be better for me to use '%jd' and (intmax_t)adj.tv_sec

					Dan
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:58:59 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 6 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:39:48 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>