Hi Neels,
On Wed, Mar 16, 2016 at 11:22:11PM +0100, Neels Hofmeyr wrote:
On Wed, Mar 16, 2016 at 11:28:30AM +0100, Harald Welte
wrote:
Why does gsm48_hdr_pdisc() not take a 'const
struct gsm48_hdr *'
argument in the first place? I don't think it modifies the contents of
the structure...
Yes, Holger has applied the patch with exactly that change.
Yet this has me confused. A while back I concluded that C doesn't allow
passing non-const instances to functions that expect a const arg.
We do that all the time in Osmocom projects. Especially for functions
that have input pointers (should be "const foo *") and output pointers
(should be "foo *), you can easily safeguard agaist some common cases
where the caller swaps the arguments this way.
This is standard practise, see the definition of memcpy:
void *memcpy(void *dest, const void *src, size_t n);
from a quick look, the above discussion was about passing the address of
a pointer, and of course if you pass that into a function, you expect
the function to be able to modify the pointer stored at that address?
--
- Harald Welte <laforge(a)gnumonks.org>
http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)