Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/usr.bin/xlint



On 26.03.2021 23:18, Christos Zoulas wrote:
In article <20210326203108.3A4E5FA96%cvs.NetBSD.org@localhost>,
Roland Illig <source-changes-d%NetBSD.org@localhost> wrote:
-=-=-=-=-=-

Module Name:	src
Committed By:	rillig
Date:		Fri Mar 26 20:31:07 UTC 2021

Modified Files:
	src/usr.bin/xlint/common: tyname.c
	src/usr.bin/xlint/lint1: cgram.y decl.c err.c func.c init.c lex.c
	    main1.c mem1.c tree.c
	src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c read.c
	src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: in malloc calls, use 'sizeof *ptr' instead of 'sizeof(type)'

style says "sizeof(" not "sizeof "

     * Casts and sizeof's are not followed by a space.

There are several forms of writing sizeof:

1. sizeof expr
2. sizeof(expr)
3. sizeof (expr)
4. sizeof(type)
5. sizeof (type)

I thought that the point of the rule you cited was to discourage forms 3
and 5.  Does the rule also discourage form 1, and if so, why?

To me, writing 'sizeof expr' is clearer than 'sizeof(expr)' since
'sizeof' is not a function, same as with 'return'.

Did I misinterpret the style guide in this regard?

Roland


Home | Main Index | Thread Index | Old Index