[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

casts considered harmful



EVERY instance of pam_get_item in all of Linux-PAM's modules has to
cast its item to a (const void **) or a (void *) in order to avoid
compiler warnings, because pam_get_item is declared to be a
const void **, and the only reasonable way to get at the data is
pam_get_item (pamh, PAM_FOO, &some_char_pointer_variable);

Why on earth do we specify a constant pointer to a pointer to a
void for this?  All it does is force people to use casts, which
are just a way to mask programmers' mistakes so that they don't
notice them until they get a hard-to-track-down bug report.

If it's because Sun decided to force people to cast around (or
if their compiler doesn't care, I don't know), can we please
remove the const in our version, and add a -DPAM_ME_HARDER
that puts the const back in for people who want to follow the
spec even when it is stupid?  Alternatively, can we simply
remove it altogether like reasonable people?

Thanks!

michaelkjohnson

"Magazines all too frequently lead to books and should be regarded by the
 prudent as the heavy petting of literature."            -- Fran Lebowitz
 Linux Application Development       http://www.redhat.com/~johnsonm/lad/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []