Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Apr 2015 21:30:08 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-standards@FreeBSD.org
Subject:   [Bug 199767] getty compile error with DEBUG flag
Message-ID:  <bug-199767-15@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=199767

            Bug ID: 199767
           Summary: getty compile error with DEBUG flag
           Product: Base System
           Version: 10.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: standards
          Assignee: freebsd-standards@FreeBSD.org
          Reporter: fbsd.bugzilla@fenyo.net

This is a very minor bug.

A printf format mismatch in /usr/src/libexec/getty/subr.c breaks compilation in
a section of the source code that is only compiled while the DEBUG constant is
#defined.

Here is the code snippet extracted from subr.c:

#ifdef DEBUG
        printf("name=\"%s\", buf=\"%s\"\r\n", name, buf);
        for (sp = gettystrs; sp->field; sp++)
                printf("cgetstr: %s=%s\r\n", sp->field, sp->value);
        for (np = gettynums; np->field; np++)
                printf("cgetnum: %s=%d\r\n", np->field, np->value);
        for (fp = gettyflags; fp->field; fp++)
                printf("cgetflags: %s='%c' set='%c'\r\n", fp->field,
                       fp->value + '0', fp->set + '0');
#endif /* DEBUG */

Here is the compilation error log:

# cd /usr/src/libexec/getty ; touch subr.c ; make DEBUG_FLAGS=-DDEBUG
cc -O2 -pipe   -DDEBUG -std=gnu99 -Qunused-arguments  -fstack-protector
-Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int
-Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value
-Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-switch
-Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses -c
/usr/src/libexec/getty/subr.c
/usr/src/libexec/getty/subr.c:169:43: error: format specifies type 'int' but
the argument has type 'long' [-Werror,-Wformat]
                printf("cgetnum: %s=%d\r\n", np->field, np->value);
                                    ~~                  ^~~~~~~~~
                                    %ld
1 error generated.
*** Error code 1
Stop.
make: stopped in /usr/src/libexec/getty

As proposed by cc, the bug is corrected by simply changing this line:
                printf("cgetnum: %s=%d\r\n", np->field, np->value);
by this one:
                printf("cgetnum: %s=%ld\r\n", np->field, np->value);

The bug occurs on every currently supported FreeBSD releases.

Sincerely,

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-199767-15>