Project

General

Profile

Bug #9367

troff: comparison between pointer and zero character constant

Added by Toomas Soome over 1 year ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
2018-03-27
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

issue found by gcc 7 build:

    ../n1.c: In function 'main':
    ../n1.c:148:17: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
         if (argv[0] != '\0') {
                     ^~
    ../n1.c:148:9: note: did you mean to dereference the pointer?
         if (argv[0] != '\0') {
             ^
    ../n1.c:184:20: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
        if (&argv[0][2] != '\0' && strlen(&argv[0][2]) >= 2 && &argv[0][3] != '\0')
                        ^~
    ../n1.c:184:8: note: did you mean to dereference the pointer?
        if (&argv[0][2] != '\0' && strlen(&argv[0][2]) >= 2 && &argv[0][3] != '\0')
            ^
    ../n1.c:184:71: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
        if (&argv[0][2] != '\0' && strlen(&argv[0][2]) >= 2 && &argv[0][3] != '\0')
                                                                           ^~
    ../n1.c:184:59: note: did you mean to dereference the pointer?
        if (&argv[0][2] != '\0' && strlen(&argv[0][2]) >= 2 && &argv[0][3] != '\0')
                                                               ^
    ../n1.c:201:28: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
        if (getenv("TROFFMACS") != '\0') {
                                ^~
    ../n1.c:201:8: note: did you mean to dereference the pointer?
        if (getenv("TROFFMACS") != '\0') {
            ^
    cc1: all warnings being treated as errors

For testing, i have used this doc to learn about register use:

https://www.gnu.org/software/groff/manual/html_node/Setting-Registers.html

So I did call:

nroff -ra2 -man ypwhich.1 | less

And I did add \na just after DESCRIPTION, so the expected outcome was to have ‘2’ printed after the description — and indeed, it was there:

     ypwhich -x

DESCRIPTION
     2

The register ‘a’ was created, set to have a value and was usable.

History

#1

Updated by Toomas Soome 11 months ago

  • Description updated (diff)
#2

Updated by Electric Monk 11 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

git commit 9fed930b55df5aeaba1280325625a29e78199a54

commit  9fed930b55df5aeaba1280325625a29e78199a54
Author: Toomas Soome <tsoome@me.com>
Date:   2018-08-14T18:05:09.000Z

    9367 troff: comparison between pointer and zero character constant
    Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
    Reviewed by: Ken Mays <kmays2000@gmail.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF