Guochun Shi wrote:
David Lee wrote:
I propose applying the attached patch early next week. But I would very
much like someone who knows the area both to sanity-check it and to
run-time check it, please.
Axiom: Part of the heartbeat ethos is that compiler warnings should be
regarded as potential errors. Indeed, the default Linux compile actually
treats warnings as errors. On Solaris, however, we haven't yet got to
that stage, but we are trying to get there. And a new set of warnings
appeared about five weeks ago...
Problem: In "lib/clplumbing/GSource.c", Solaris (probably more
accurately
sparc-architecture) compilations get multiple warnings of the form:
[...]/GSource.c:239: warning: cast increases required alignment of
target type
caused by the use of " longclock_t detecttime" in structures. This is a
large type (typically "long long"), which, on some architectures,
requires
the space to be similarly aligned. But the code cannot guarantee this
and this is detected at runtime.
I don't understand the cause of the problem. GSource.c:239:
ret->detecttime = zero_longclock;
where detecttime is "longclock_t", and zero_longclock is "const
longclock_t". They should have the same size
and same allignment, no matter what arch it is
anyone enlighten me please?
The problem is that the structure is never guaranteed to be aligned to
boundaries more stringent than the largest object in the GSource*
object. GSource objects only have longs in them, not long longs. So,
it isn't guaranteed to be right.
In practice it should be right if the storage comes from malloc, but
will NOT be guaranteed to be right if it comes from a local variable.
The compiler can't tell where the pointer being passed comes from so it
will complain, because it can't _guarantee_ that the alignment of the
pointer is correct.
Hope that helps!
--
Alan Robertson <[EMAIL PROTECTED]>
"Openness is the foundation and preservative of friendship... Let me
claim from you at all times your undisguised opinions." - William
Wilberforce
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/