Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jul 2003 01:19:56 -0700
From:      Luigi Rizzo <rizzo@icir.org>
To:        current@freebsd.org
Subject:   what is the suggested way to do void * arithmetic ?
Message-ID:  <20030710011956.A61125@xorpc.icir.org>

next in thread | raw e-mail | index | archive | help

Hi,
in several places in ipfw2.c i have to move pointers across
structures of variable length (lists of ipfw2 instructions
returned by the getsockopt()), and i use the following type of code:

	void *next;
	foo *p;

	...

	next = (void *)p + len;
	...
	foo = (foo *)p + len;

When using WARNS=5, the compiler in -current flags them with 'Warning
void * arithmetic'.

What is the best way to do the above given that i do need to use
these variable-size structures ?

	cheers
	luigi



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