Subject: [ntpwg] [Technical Errata Reported] RFC5905 (3404)

From: RFC Errata System <[email-masked]>
Date: Thu, 8 Nov 2012 23:12:46 -0800 (PST)

The following errata report has been submitted for RFC5905,
"Network Time Protocol Version 4: Protocol and Algorithms Specification".

--------------------------------------
You may review the report below and at:
http://www.rfc-editor.org/errata_search.php?rfc=5905&eid=3404

--------------------------------------
Type: Technical
Reported by: Philippe Verdy <[email-masked]>

Section: A.1.1.

Original Text
-------------
#define SQUARE(x)       (x * x)

Corrected Text
--------------
#define SQUARE(x)       ((x) * (x))

Notes
-----
This macro is used in the example code to square differences:

//- in clock_filter() {...} (page 85) :

                p->jitter += SQUARE(f[i].offset - f[0].offset);

//- in clock_select() { ... } (page 92) :

                                dtemp += SQUARE(p->offset - q->offset);

//- in clock_combine() { ... } (page 96) :

                w += SQUARE(p->offset - s.v[0].p->offset) / x;

//- in local_clock() { ... } (page 99) :

                dtemp = SQUARE(max(fabs(offset - c.last),

                    LOG2D(s.precision)));

These expressions are using differences of double values: the .offset member in a Filter stage structure (f), and the .jitter member in an Association structure (p), or in a Local clock structure (c), or in a System structure (s).

All these occurences of macro substitions of SQUARE() will be wrong if the C macro does not surrounds its parameter expression by adding parentheses around them !

This is a very classic error made by beginners in C programming using "utility" macros with side effects... At least newer programmers avoid these kind of macros and prefer defining inline functions

Instructions:
-------------
This errata is currently posted as "Reported". If necessary, please
use "Reply All" to discuss whether it should be verified or
rejected. When a decision is reached, the verifying party (IESG)
can log in to change the status and edit the report, if necessary. 

--------------------------------------
RFC5905 (draft-ietf-ntp-ntpv4-proto-13)
--------------------------------------
Title               : Network Time Protocol Version 4: Protocol and Algorithms Specification
Publication Date    : June 2010
Author(s)           : D. Mills, J. Martin, Ed., J. Burbank, W. Kasch
Category            : PROPOSED STANDARD
Source              : Network Time Protocol
Area                : Internet
Stream              : IETF
Verifying Party     : IESG
_______________________________________________
ntpwg mailing list
[email-masked]
http://lists.ntp.org/listinfo/ntpwg