Xref: utzoo comp.lang.c:16513 comp.windows.x:8262 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!wiley!spp2!ries%arcturus From: ries@arcturus (Marc Ries) Newsgroups: comp.lang.c,comp.windows.x Subject: Linting a routine using varargs (WidgetSet()) Summary: I can't, why not? Keywords: lint, VARARGS, varargs Message-ID: <1665@spp2.UUCP> Date: 24 Feb 89 22:46:02 GMT Sender: news@spp2.UUCP Reply-To: ries@spp2.UUCP (Marc Ries) Organization: TRW SEDD Lines: 78 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.UUCP