[Bug 199767] getty compile error with DEBUG flag

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Apr 28 21:30:08 UTC 2015


            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 at FreeBSD.org
          Reporter: fbsd.bugzilla at 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

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: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);
                                    ~~                  ^~~~~~~~~
1 error generated.
*** Error code 1
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.


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

More information about the freebsd-standards mailing list