ries@arcturus (Marc Ries) (02/25/89)
Ok. Flame me, beat me, make me write bad code! 8-)
I have an X program that is using the recently posted
utility function called "WidgetSet". I can't get lint
to shut up about things like:
==========
WidgetSet: variable # of args. myprog.c(433) :: myprog.c(532)
431 DwtNadbLeftAttachment, DwtAttachWidget,
432 DwtNadbLeftWidget, namelabel,
433 >>> DwtNadbRightAttachment, DwtAttachAdb, NULL);
530 DwtNadbLeftAttachment, DwtAttachAdb,
531 DwtNadbBottomAttachment, DwtAttachAdb,
532 >>> DwtNadbRightAttachment, DwtAttachAdb, NULL);
WidgetSet, arg. 3 used inconsistently myprog.c(433) :: myprog.c(532)
431 DwtNadbLeftAttachment, DwtAttachWidget,
432 DwtNadbLeftWidget, namelabel,
433 >>> DwtNadbRightAttachment, DwtAttachAdb, NULL);
530 DwtNadbLeftAttachment, DwtAttachAdb,
531 DwtNadbBottomAttachment, DwtAttachAdb,
532 >>> DwtNadbRightAttachment, DwtAttachAdb, NULL);
WidgetSet, arg. 5 used inconsistently myprog.c(433) :: myprog.c(532)
...
==========
The actual WidgetSet function looks like this:
==========
/*VARARGS*/
void
WidgetSet(va_alist)
va_dcl
{
String argstr;
Arg args[MAXARGS];
XtArgVal argval;
int i = 0;
va_list var;
Widget w;
va_start(var);
w = va_arg(var, Widget);
while (argstr = va_arg(var, char *)) {
if (i == MAXARGS) {
fprintf(stderr, "Warning: increase MAXARGS! (%d)\n", i);
XtSetValues(w, args, i);
i = 0;
}
if (!strcmp(argstr, XtNargList)) {
ArgList list = va_arg(var, ArgList);
XtArgVal numargs = va_arg(var, Cardinal);
XtSetValues(w, list, numargs);
} else {
argval = va_arg(var, XtArgVal);
XtSetArg(args[i], argstr, argval);
++i;
}
}
va_end(var);
if (i > 0)
XtSetValues(w, args, i);
}
==========
I've gone thru a bunch of old NETNEWS programs that use
functions created with VARARGS, and even RTFM on things
like vprintf(), but still don't see the light.
I understand why lint is complaining, and I know that the
program runs fine as is.
Is a dummy version of WidgetSet needed withing my program?
Is there a solution? Thanks for any pointers.
Marc Ries
TRW Defense Systems Group/HMI
UUCP: ...!spp2!ries@trwspp.UUCPries@arcturus (Marc Ries) (02/28/89)
Might also mention that (in pursuit of the truth 8-*)
I have tried the lint /*VARARGS*/ flag, both just
before the invocation of my call to WigetSet() as well
as just before the routine that contains the WidgetSet call.
Neither made a difference. Both my program,
and the actual PD WidgetSet() routines, see
NULL defined as a zero.
The calls to WidgetSet() are setup along these lines:
static Widget
do_it(parent)
Widget parent;
{
Arg al[25];
int ac = 0;
Widget ...;
...
XtSetArg(al[ac], ....);
ac++;
(Widget) mytextwidget = DwtSTextCreate(parent, "mylabel", al, ac);
WidgetSet(mytextwidget,
DwtNfocusCallback, my_callback,
DwtNadbTopAttachment, DwtAttachOppWidget,
DwtNadbTopWidget, abovewidget,
DwtNadbLeftAttachment, DwtAttachWidget,
DwtNadbLeftWidget, abovewidget,
DwtNadbRightAttachment, DwtAttachAdb,
NULL);
XtManageChild(mytextwidget);
...
}
Marc Ries
TRW Defense Systems Group/HMI
UUCP: ...!spp2!ries@trwspp.UUCP