[PATCH XTS 2/2] xts5: Fix 'missing sentinel in function call' warnings by using literal NULL

Peter Hutterer peter.hutterer at who-t.net
Wed Apr 13 21:25:17 PDT 2011


On Tue, Apr 12, 2011 at 05:29:07PM -0700, Aaron Plattner wrote:
> Various Xlib list functions use variable-length argument lists.
> While the spec is vague, the prototypes in the Xlib headers mark the
> functions as taking sentinal values of NULL.
> 
> In some cases, the sentinal value was not being passed.  Fix those.
> 
> In other cases, XTS does this:
> 
>   char *endlist = NULL;
>   function(..., endlist);
> 
> While this is perfectly valid, GCC warns about it anyway.  Switch
> these to using literal NULLs too.
> 
> Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
> ---
>  xts5/Xlib14/XGetICValues.m        |    2 +-
>  xts5/Xlib14/XGetIMValues.m        |    2 +-
>  xts5/Xlib14/XSetICFocus.m         |    2 +-
>  xts5/Xlib14/XSetICValues.m        |   28 ++++++++++++++--------------
>  xts5/Xlib14/XVaCreateNestedList.m |   35 ++++++++++++++++-------------------
>  5 files changed, 33 insertions(+), 36 deletions(-)
> 
> diff --git a/xts5/Xlib14/XGetICValues.m b/xts5/Xlib14/XGetICValues.m
> index c2c8874..f27f119 100644
> --- a/xts5/Xlib14/XGetICValues.m
> +++ b/xts5/Xlib14/XGetICValues.m
> @@ -158,7 +158,7 @@ char *
>  XIC ic;
>  char *ic_name;
>  ic_val_def *ic_val;
> -int endlist = 0;
> +NULL
>  >>EXTERN
>  
>  static char *pe_names[] = {
> diff --git a/xts5/Xlib14/XGetIMValues.m b/xts5/Xlib14/XGetIMValues.m
> index 8e957a8..bf875ee 100644
> --- a/xts5/Xlib14/XGetIMValues.m
> +++ b/xts5/Xlib14/XGetIMValues.m
> @@ -115,7 +115,7 @@ char *
>  XIM im = NULL;
>  char *im_name = XNQueryInputStyle;
>  XIMStyles **pstyle = NULL;
> -int end_of_list = NULL;
> +NULL
>  >>SET startup localestartup
>  >>SET cleanup localecleanup
>  >>ASSERTION Good C
> diff --git a/xts5/Xlib14/XSetICFocus.m b/xts5/Xlib14/XSetICFocus.m
> index d01403f..0c7f3da 100644
> --- a/xts5/Xlib14/XSetICFocus.m
> +++ b/xts5/Xlib14/XSetICFocus.m
> @@ -193,7 +193,7 @@ for (i1 = 0; i1 < regr_args.iter; i1++) {
>  
>  	if ((regr_args.l_flags.check) && (errflg == 0) && 
>  		(stat_status == REGR_NORMAL)) {
> -		XGetICValues(ic_value, XNFocusWindow, &ret_window) ;
> +		XGetICValues(ic_value, XNFocusWindow, &ret_window, NULL);
>  		check_dec(window_id_good, ret_window, "window id") ;
>  		}
>  
> diff --git a/xts5/Xlib14/XSetICValues.m b/xts5/Xlib14/XSetICValues.m
> index ed5a74e..5cadaec 100644
> --- a/xts5/Xlib14/XSetICValues.m
> +++ b/xts5/Xlib14/XSetICValues.m
> @@ -170,7 +170,7 @@ char *
>  XIC ic;
>  char *ic_name;
>  ic_val_def *ic_val;
> -char *endlist = NULL;
> +NULL
>  >>SET startup fontstartup
>  >>SET cleanup fontcleanup
>  >>EXTERN
> @@ -531,7 +531,7 @@ ic_list_def *il;
>  					/* fetch the values */
>  					ret_icv = &icv;
>  					pstr = XGetICValues(ic,ic_name,
> -						(XPointer)&ret_icv,endlist);
> +						(XPointer)&ret_icv, NULL);
>  					if(pstr != NULL && *pstr != '\0')
>  					{
>  						report("XGetICValues returns non-null result, %s",
> @@ -707,28 +707,28 @@ char name[128];
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->val_long,
> -						endlist);
> +						NULL);
>  				}
>  				else if(ils->type == ICV_WINDOW)
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->win,
> -						endlist);
> +						NULL);
>  				}
>  				else if(ils->type == ICV_INT)
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->val_int,
> -						endlist);
> +						NULL);
>  				}
>  				else
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val,
> -						endlist);
> +						NULL);
>  				}
>  
>  				ic_name = name;
> @@ -748,9 +748,9 @@ char name[128];
>  					ret_att.va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)&ret_icv,
> -						endlist);
> +						NULL);
>  					pstr = XGetICValues(ic,ic_name,
> -						(XPointer)ret_att.va,endlist);
> +						(XPointer)ret_att.va, NULL);
>  					if(pstr != NULL && *pstr != '\0')
>  					{
>  						report("XGetICValues returns non-null result, %s",
> @@ -934,28 +934,28 @@ char name[128];
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->val_long,
> -						endlist);
> +						NULL);
>  				}
>  				else if(ils->type == ICV_WINDOW)
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->win,
> -						endlist);
> +						NULL);
>  				}
>  				else if(ils->type == ICV_INT)
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->val_int,
> -						endlist);
> +						NULL);
>  				}
>  				else
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val,
> -						endlist);
> +						NULL);
>  				}
>  				ic_name = name;
>  				ic_val = (ic_val_def *)att->va;
> @@ -974,9 +974,9 @@ char name[128];
>  					ret_att.va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)&ret_icv,
> -						endlist);
> +						NULL);
>  					pstr = XGetICValues(ic,ic_name,
> -						(XPointer)ret_att.va,endlist);
> +						(XPointer)ret_att.va, NULL);
>  					if(pstr != NULL && *pstr != '\0')
>  					{
>  						report("XGetICValues returns non-null result, %s",
> diff --git a/xts5/Xlib14/XVaCreateNestedList.m b/xts5/Xlib14/XVaCreateNestedList.m
> index 62e3d83..297ac17 100644
> --- a/xts5/Xlib14/XVaCreateNestedList.m
> +++ b/xts5/Xlib14/XVaCreateNestedList.m
> @@ -165,7 +165,7 @@ typedef struct ICL {
>  XVaNestedList
>  
>  int dummy;
> -char *endlist = NULL;
> +NULL
>  >>SET startup localestartup
>  >>SET cleanup localecleanup
>  >>EXTERN
> @@ -460,7 +460,6 @@ char *plocale;
>  XIC ic;
>  char *ic_name;
>  ic_val_def *ic_val;
> -char *endlist = NULL;
>  Display *dpy;
>  XIM im = NULL;
>  XFontSet fs = NULL;
> @@ -562,27 +561,27 @@ char name[128];
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->val_long,
> -						endlist);
> +						NULL);
>  				}
>  				else if(ils->type == ICV_INT)
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val->val_int,
> -						endlist);
> +						NULL);
>  				}
>  				else
>  				{
>  					att->va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)ils->val,
> -						endlist);
> +						NULL);
>  				}
>  				ic_name = name;
>  				ic_val = (ic_val_def *)att->va;
>  
>  				pstr = XSetICValues(ic, ic_name, 
> -					(XPointer)ic_val, endlist);
> +					(XPointer)ic_val, NULL);
>  				if(pstr != NULL && *pstr != '\0')
>  				{
>  					report("%s() returns non-null result, %s",
> @@ -596,9 +595,9 @@ char name[128];
>  					ret_att.va = XVaCreateNestedList(dummy,
>  						ils->name,
>  						(XPointer)&ret_icv,
> -						endlist);
> +						NULL);
>  					pstr = XGetICValues(ic,ic_name,
> -						(XPointer)ret_att.va,endlist);
> +						(XPointer)ret_att.va, NULL);
>  					if(pstr != NULL && *pstr != '\0')
>  					{
>  						report("XGetICValues returns non-null result, %s",
> @@ -661,7 +660,6 @@ char *ic_name;
>  ic_val_def 	*ic_val;
>  char 		*ic_name1, *ic_name2;
>  ic_val_def	*picv;
> -char *endlist = NULL;
>  Display *dpy;
>  XIM im = NULL;
>  XFontSet fs = NULL;
> @@ -789,12 +787,12 @@ int		index1, index2;
>  			{
>  			 	att->va = XVaCreateNestedList(dummy,
>  					ic_name1, val1, ic_name2, val2,
> -					endlist);
> +					NULL);
>  				ic_val = (ic_val_def *)att->va;
>  				ic_name = name;
>  
>  				pstr = XSetICValues(ic, ic_name,
> -					(XPointer)ic_val, endlist);
> +					(XPointer)ic_val, NULL);
>  				if(pstr != NULL && *pstr != '\0')
>  				{
>  					report("%s() returns non-null result, %s",
> @@ -822,9 +820,9 @@ int		index1, index2;
>  						ret_att.va = XVaCreateNestedList(dummy,
>  							ils->name,
>  							(XPointer)&ret_icv,
> -							endlist);
> +							NULL);
>  						pstr = XGetICValues(ic,ic_name,
> -							(XPointer)ret_att.va,endlist);
> +							(XPointer)ret_att.va, NULL);
>  						if(pstr != NULL && *pstr != '\0')
>  						{
>  							report("XGetICValues returns non-null result, %s",
> @@ -890,7 +888,6 @@ char *ic_name;
>  ic_val_def 	*ic_val;
>  char 		*ic_name1, *ic_name2;
>  ic_val_def	*picv;
> -char *endlist = NULL;
>  Display *dpy;
>  XIM im = NULL;
>  XFontSet fs = NULL;
> @@ -1019,16 +1016,16 @@ XVaNestedList	va_temp;
>  			{
>  			 	va_temp = XVaCreateNestedList(dummy,
>  					ic_name1, (XPointer)val1,
> -					endlist);
> +					NULL);
>  			 	att->va = XVaCreateNestedList(dummy,
>  					XNVaNestedList, (XPointer)va_temp,
>  					ic_name2, (XPointer)val2,
> -					endlist);
> +					NULL);
>  				ic_val = (ic_val_def *)att->va;
>  				ic_name = name;
>  
>  				pstr = XSetICValues(ic, ic_name,
> -					(XPointer)ic_val, endlist);
> +					(XPointer)ic_val, NULL);
>  				if(pstr != NULL && *pstr != '\0')
>  				{
>  					report("%s() returns non-null result, %s",
> @@ -1058,9 +1055,9 @@ tet_infoline("5");
>  						ret_att.va = XVaCreateNestedList(dummy,
>  							ils->name,
>  							(XPointer)&ret_icv,
> -							endlist);
> +							NULL);
>  						pstr = XGetICValues(ic,ic_name,
> -							(XPointer)ret_att.va,endlist);
> +							(XPointer)ret_att.va, NULL);
>  						if(pstr != NULL && *pstr != '\0')
>  						{
>  							report("XGetICValues returns non-null result, %s",
> -- 
> 1.7.1

Acked-by: Peter Hutterer <peter.hutterer at who-t.net> to both of them.

Cheers,
  Peter


More information about the xorg-devel mailing list