Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: GnuPG: devel

gnupg-2.0.13: unwanted gcc-ism in source code, and a needed library

 

 

GnuPG devel RSS feed   Index | Next | Previous | View Threaded


beebe at math

Oct 12, 2009, 2:15 PM

Post #1 of 2 (104 views)
Permalink
gnupg-2.0.13: unwanted gcc-ism in source code, and a needed library

I've made some further progress in getting gnupg-2.0.13 installed on
various local Unix platforms, and today, hit an apparent gcc-ism in
the source code:

% cd tests
% sed -n 202p asschk.c
#define die(format, args...) (die) ("%s: " format, __func__ , ##args) %%

Compiling this single file with gcc, and using the native compiler on
all other files, was sufficient to get this release on build on Sun
Solaris (SPARC, AMD64, and IA-32).

A check of the text of the 1999 ISO C Standard shows this
specification of the use of variable numbers of arguments in macro
definitions:

6.10.3 Macro replacement
...
4 If the identifier-list in the macro definition does not end with an
ellipsis, the number of arguments (including those arguments
consisting of no preprocessing tokens) in an invocation of a
function-like macro shall equal the number of parameters in the
macro definition. Otherwise, there shall be more arguments in the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
invocation than there are parameters in the macro definition
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(excluding the ...). There shall exist a ) preprocessing token that
terminates the invocation.

The gnupg code seems to violate that highlighted requirement, since it
has subsequent statement like

die ("out of core");
die ("received line too large");

after the macro definition. Also, the Standard's syntax description
does not appear to permit a comma to be omitted before the ellipsis.

The Sun c99 compiler on this test file

% cat foo-die.c
extern void die (const char *format, ...);

#define die(format, args, ...) (die) ("%s: " format, __func__ , ##args)

void
foo()
{
die("test 1"); /* line 8 */
die("test 1", "test 2"); /* line 9 */
die("test 1", "test 2", "test 3"); /* line 10 */
}

produces these errors:

% c99 -c foo-die.c
"foo-die.c", line 8: warning: argument mismatch
"foo-die.c", line 8: syntax error before or at: )
"foo-die.c", line 9: warning: argument mismatch
c99: acomp failed for foo-die.c

Notice that lines 8 and 9 elicit a diagnostic, but line 10, which has
the required minimum number of arguments, does not.

Inasmuch as this is the ONLY file in this gnupg release that uses this
C99 feature, I suggest that it would be better to remove it, in the
interests of gnupg being compilable by a wider range of compilers.

Also, linking of this release on Solaris fails with nanosleep()
unresolved. Restarting the build with

make LIBS=-lrt

resolves that problem. The -lrt (real-time) library is needed on
several systems for features like high-precision timers, so configure
scripts should be written to find whether -lrt is needed on a given
build host.

-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- University of Utah FAX: +1 801 581 4148 -
- Department of Mathematics, 110 LCB Internet e-mail: beebe[at]math.utah.edu -
- 155 S 1400 E RM 233 beebe[at]acm.org beebe[at]computer.org -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------

_______________________________________________
Gnupg-devel mailing list
Gnupg-devel[at]gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel


wk at gnupg

Oct 13, 2009, 1:00 AM

Post #2 of 2 (96 views)
Permalink
Re: gnupg-2.0.13: unwanted gcc-ism in source code, and a needed library [In reply to]

On Mon, 12 Oct 2009 23:15, beebe[at]math.utah.edu said:

> The gnupg code seems to violate that highlighted requirement, since it
> has subsequent statement like
>
> die ("out of core");
> die ("received line too large");
>
> after the macro definition. Also, the Standard's syntax description
> does not appear to permit a comma to be omitted before the ellipsis.

Thanks for pointing this out.

> Inasmuch as this is the ONLY file in this gnupg release that uses this
> C99 feature, I suggest that it would be better to remove it, in the
> interests of gnupg being compilable by a wider range of compilers.

Right, our policy is to use C-90 thus vararg macros should not be used.
I replaced that by die_0, die_1 etc, macros.

> Also, linking of this release on Solaris fails with nanosleep()
> unresolved. Restarting the build with
>
> make LIBS=-lrt

I'll take care of that later. I also need to read through the reports
you sent me a couple of weeks ago.


Salam-Shalom,

Werner

--
Die Gedanken sind frei. Auschnahme regelt ein Bundeschgesetz.


_______________________________________________
Gnupg-devel mailing list
Gnupg-devel[at]gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-devel

GnuPG devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.