Solaris compile warnings

Vernon Schryver vjs@calcite.rhyolite.com
Tue Feb 4 19:27:38 UTC 2003


> From: "Sven" <sven@dmv.com>

> In an effort to add to the solaris pool of knowledge, I wanted to point out
> the following warning when compiling dccd:
>
> db.c:1390: warning: cast increases required alignment of target type
>
> and in various other spots in db.c
>
> Hasn't affected the functionality of the dccd to date, but something to keep
> in mind for future development (I think the alignment issue comes into play
> more when an app is multithreaded, but don't quote me on that ..........)

When I've checked the causes of those warnings, I've found they result
from casting data such chars to longs.  For example, line 1390 of
srvrlib/db.c is

        st->d.r = (DB_RCD *)&b->buf.c[pg_off];

A DB_RCD contains a u_int32_t and so must be aligned on an 4-byte
boundary on hardware that enforces "natural alighment."  All of the
records in the database are multiples of 12 bytes and the buffers
used to map the database file are page-align.  That ensures that
that st->d.r gets a pointer that is divisible by 4.

I wish there were a way to tell the compiler "don't worry about 
this particular potential error here."

I think the alternative of doing a byte-copy is unacceptable.


Vernon Schryver    vjs@rhyolite.com



More information about the DCC mailing list

Contact vjs@rhyolite.com by mail or use the form.