From 59bcb8d08f18a0274326444ae92adceec64edec3 Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Tue, 30 Dec 2014 15:57:12 +0000 Subject: [PATCH] dsdm: convert k&r function declarations to ansi, and correct the warnings this then uncovered. --- cde/programs/dsdm/dsdm.c | 74 +++++--------------- cde/programs/dsdm/proxy.c | 140 +++++++++++--------------------------- 2 files changed, 56 insertions(+), 158 deletions(-) diff --git a/cde/programs/dsdm/dsdm.c b/cde/programs/dsdm/dsdm.c index 805a3f9f..fb869bdf 100644 --- a/cde/programs/dsdm/dsdm.c +++ b/cde/programs/dsdm/dsdm.c @@ -157,10 +157,7 @@ typedef struct { * Flash the visible region. Useful for debugging. */ void -FlashRegion(dpy, s, gc) - Display *dpy; - int s; - GC gc; +FlashRegion(Display *dpy, int s, GC gc) { XEvent e; Bool done = False; @@ -193,8 +190,7 @@ FlashRegion(dpy, s, gc) void -FlashDropSites(dpy) - Display *dpy; +FlashDropSites(Display *dpy) { drop_site_t *site = MasterSiteList; XGCValues gcv; @@ -234,16 +230,10 @@ FlashDropSites(dpy) */ #ifdef oldcode void * +GetInterestProperty(Display *dpy, Window win, int *nitems) #else unsigned char * -#endif -GetInterestProperty(dpy, win, nitems) - Display *dpy; - Window win; -#ifdef oldcode - int *nitems; -#else - unsigned long *nitems; +GetInterestProperty(Display *dpy, Window win, unsigned long *nitems) #endif { Status s; @@ -306,12 +296,7 @@ GetInterestProperty(dpy, win, nitems) * children of this window are searched. */ Bool -FindRecursively(dpy, root, win, pwin, psite, plen, px, py) - Display *dpy; - Window root, win, *pwin; - void **psite; - unsigned long *plen; - int *px, *py; +FindRecursively(Display *dpy, Window root, Window win, Window *pwin, void **psite, unsigned long *plen, int *px, int *py) { XWindowAttributes attr; Window junk; @@ -437,20 +422,9 @@ FindRecursively(dpy, root, win, pwin, psite, plen, px, py) */ Bool #ifdef oldcode -SearchChildren(dpy, root, win, pwin, psite, plen, px, py) - Display *dpy; - Window root, win, *pwin; - void **psite; - unsigned long *plen; - int *px, *py; +SearchChildren(Display *dpy, Window root, Window win, Window *pwin, void **psite, unsigned long *plen, int *px, int *py) #else -SearchChildren(dpy, root, win, pwin, psite, plen, px, py, from_FindRec) - Display *dpy; - Window root, win, *pwin; - void **psite; - unsigned long *plen; - int *px, *py; - Bool from_FindRec; +SearchChildren(Display *dpy, Window root, Window win, Window *pwin, void **psite, unsigned long *plen, int *px, int *py, Bool from_FindRec) #endif { Window junk; @@ -488,9 +462,7 @@ SearchChildren(dpy, root, win, pwin, psite, plen, px, py, from_FindRec) * Create and return a region that contains a given rectangle. */ Region -MakeRegionFromRect(x, y, w, h) - int x, y; - unsigned int w, h; +MakeRegionFromRect(int x, int y, unsigned int w, unsigned int h) { XRectangle r; Region reg; @@ -513,10 +485,7 @@ MakeRegionFromRect(x, y, w, h) * corner is at (0,0). */ Region -GetWindowRegion(dpy, win, offset) - Display *dpy; - Window win; - Bool offset; +GetWindowRegion(Display *dpy, Window win, Bool offset) { Window wjunk; int x, y; @@ -543,10 +512,7 @@ GetWindowRegion(dpy, win, offset) * Subtract the area of a window from the current visible region. */ void -SubtractWindowFromVisibleRegion(dpy, win, visrgn) - Display *dpy; - Window win; - Region visrgn; +SubtractWindowFromVisibleRegion(Display *dpy, Window win, Region visrgn) { Region winrgn = GetWindowRegion(dpy, win, True); XSubtractRegion(visrgn, winrgn, visrgn); @@ -698,8 +664,7 @@ ProcessInterestProperty(dpy, win, screen, data, datalen, visrgn, xoff, yoff) * forwarding information to the site database. */ void -FindDropSites(dpy) - Display *dpy; +FindDropSites(Display *dpy) { #ifdef oldcode int s, i, nchildren; @@ -808,7 +773,7 @@ FindDropSites(dpy) void -FreeDropSites() +FreeDropSites(void) { drop_site_t *next, *temp; @@ -843,10 +808,7 @@ FreeDropSites() * 8k+7 flags */ void -WriteSiteRectList(dpy, win, prop) - Display *dpy; - Window win; - Atom prop; +WriteSiteRectList(Display *dpy, Window win, Atom prop) { unsigned long *cur; unsigned long *array; @@ -911,9 +873,7 @@ WriteSiteRectList(dpy, win, prop) * site database. REMIND: more robust error handling is called for. */ int -ErrorHandler(dpy, error) - Display *dpy; - XErrorEvent *error; +ErrorHandler(Display *dpy, XErrorEvent *error) { if ( (error->error_code == BadWindow || error->error_code == BadDrawable) && @@ -936,9 +896,8 @@ ErrorHandler(dpy, error) } /* end of ErrorHandler */ -main(argc, argv) - int argc; - char **argv; +int +main(int argc, char **argv) { enum { XA_SUN_DRAGDROP_DSDM, XA_SUN_DRAGDROP_INTEREST, XA_SUN_DRAGDROP_SITE_RECTS, XAWM_STATE, NUM_ATOMS }; @@ -1082,3 +1041,4 @@ main(argc, argv) #endif } } /* end of main */ + diff --git a/cde/programs/dsdm/proxy.c b/cde/programs/dsdm/proxy.c index 832cc910..3de6e0e4 100644 --- a/cde/programs/dsdm/proxy.c +++ b/cde/programs/dsdm/proxy.c @@ -207,7 +207,7 @@ Window motif_drag_win; char motif_byte_order; void -InitializeByteOrder() +InitializeByteOrder(void) { unsigned int endian = 1; @@ -219,9 +219,8 @@ InitializeByteOrder() } /* swap 2 bytes of data if the byte order is different */ -Swap2Bytes(byte_order, data) - char byte_order; - CARD16 data; +int +Swap2Bytes(char byte_order, CARD16 data) { static CARD16 ret_data; char *old_p = (char *) &data; @@ -236,9 +235,8 @@ Swap2Bytes(byte_order, data) } /* swap 4 bytes of data if the byte order is different */ -Swap4Bytes(byte_order, data) - char byte_order; - CARD32 data; +int +Swap4Bytes(char byte_order, CARD32 data) { static CARD32 ret_data; char *old_p = (char *) &data; @@ -258,7 +256,7 @@ Swap4Bytes(byte_order, data) /* Get a new drop record */ /* use source_handle to indicate whether record is free or in use */ static drop_info_t * -NewDropInfo() +NewDropInfo(void) { int i, oldest_index=0; @@ -278,8 +276,7 @@ NewDropInfo() /* Search for a drop record */ /* use source_handle as the key to the drop_info record */ static drop_info_t * -GetDropInfo(proxy_sel_req_win) - Window proxy_sel_req_win; +GetDropInfo(Window proxy_sel_req_win) { int i; @@ -292,8 +289,7 @@ GetDropInfo(proxy_sel_req_win) /* Search for a drop record using the proxy_handle as the key */ static drop_info_t * -GetDropInfoUsingProxyHandle(proxy_handle) - Atom proxy_handle; +GetDropInfoUsingProxyHandle(Atom proxy_handle) { int i; @@ -306,8 +302,7 @@ GetDropInfoUsingProxyHandle(proxy_handle) /* Delete a drop record */ static void -ClearDropInfo(proxy_handle) - Atom proxy_handle; +ClearDropInfo(Atom proxy_handle) { int i; for(i=0; i= x) && (drop_x <= (x+width)) && (drop_y >= y) && (drop_y <= (y+height))) @@ -568,12 +551,8 @@ InRect(drop_x, drop_y, x, y, width, height) /* get the drop site given the window and coordinate */ static void -GetOlitDropSite(dpy, top_level_win, drop_x, drop_y, ret_site_id, ret_event_win) - Display *dpy; - Window top_level_win; - INT16 drop_x, drop_y; - unsigned long *ret_site_id; - Window *ret_event_win; +GetOlitDropSite(Display *dpy, Window top_level_win, INT16 drop_x, INT16 drop_y, + unsigned long *ret_site_id, Window *ret_event_win) { unsigned long *data, nitems, version, nsites, event_win, site_id, flags; unsigned long areatype, nrects, areawin; @@ -659,8 +638,7 @@ GetOlitDropSite(dpy, top_level_win, drop_x, drop_y, ret_site_id, ret_event_win) /* translate an OLIT operation to a Motif operation */ static CARD16 -ConvertOlitAction(olit_action) - CARD32 olit_action; +ConvertOlitAction(CARD32 olit_action) { CARD16 motif_action; @@ -676,8 +654,7 @@ ConvertOlitAction(olit_action) /* translate a Motif operation to an OLIT operation */ static CARD32 -ConvertMotifAction(motif_action) - CARD16 motif_action; +ConvertMotifAction(CARD16 motif_action) { CARD32 olit_action; @@ -695,9 +672,7 @@ ConvertMotifAction(motif_action) /* Process Motif ClientMessage */ void -HandleMotifMessage(dpy, event) - Display *dpy; - XClientMessageEvent *event; +HandleMotifMessage(Display *dpy, XClientMessageEvent *event) { motif_drop_start_t info; drop_info_t *drop_info; @@ -791,9 +766,7 @@ HandleMotifMessage(dpy, event) /* Process OLIT ClientMessage */ static void -HandleOlitTrigger(dpy, event) - Display *dpy; - XClientMessageEvent *event; +HandleOlitTrigger(Display *dpy, XClientMessageEvent *event) { drop_site_t *site; char success = False; @@ -852,11 +825,7 @@ HandleOlitTrigger(dpy, event) /* Place the Motif initiator property on the initiator's top level window */ static void -UpdateInitiatorAtom(dpy, win, channel, targets_index) - Display *dpy; - Window win; - Atom channel; - CARD16 targets_index; +UpdateInitiatorAtom(Display *dpy, Window win, Atom channel, CARD16 targets_index) { motif_initiator_t initiator_info; @@ -877,10 +846,7 @@ UpdateInitiatorAtom(dpy, win, channel, targets_index) /* Send Motif DROP_START ClientMessage to receiver */ void -SendStartDrop(dpy, src_win, drop_info) - Display *dpy; - Window src_win; - drop_info_t *drop_info; +SendStartDrop(Display *dpy, Window src_win, drop_info_t *drop_info) { motif_drop_start_t info; XClientMessageEvent event; @@ -906,17 +872,17 @@ SendStartDrop(dpy, src_win, drop_info) /* Compare data of type Atom */ static int -AtomCompare(atom1, atom2) - Atom *atom1, *atom2; +AtomCompare(const void *a1, const void *a2) { + const Atom *atom1 = a1; + const Atom *atom2 = a2; + return(*atom1 - *atom2); } /* Get the Motif TARGETS */ static void -GetTargetsList(dpy, targets_list_p) - Display *dpy; - motif_targets_t **targets_list_p; +GetTargetsList(Display *dpy, motif_targets_t **targets_list_p) { motif_targets_t *targets_list; Atom type; @@ -946,11 +912,7 @@ GetTargetsList(dpy, targets_list_p) } static void -MatchTargets(targets_list, atoms, atom_cnt, targets_index_p) - motif_targets_t *targets_list; - Atom *atoms; - unsigned long atom_cnt; - CARD16 *targets_index_p; +MatchTargets(motif_targets_t *targets_list, Atom *atoms, unsigned long atom_cnt, CARD16 *targets_index_p) { int target_index; CARD32 *data; @@ -989,11 +951,7 @@ MatchTargets(targets_list, atoms, atom_cnt, targets_index_p) /* Put OLIT targets on the Motif TARGETS targets list */ static void -GetTargetsIndex(dpy, in_data, atom_cnt, targets_index_p) - Display *dpy; - unsigned char *in_data; - unsigned long atom_cnt; - CARD16 *targets_index_p; /* RETURN */ +GetTargetsIndex(Display *dpy, unsigned char *in_data, unsigned long atom_cnt, CARD16 *targets_index_p) { Atom *atoms = (Atom *) in_data; motif_targets_t *new_list, *targets_list; @@ -1056,11 +1014,7 @@ GetTargetsIndex(dpy, in_data, atom_cnt, targets_index_p) * send DROP_START message to motif receiver */ static void -ContinueHandleOlitTrigger(dpy, data, length, drop_info) - Display *dpy; - unsigned char *data; - unsigned long length; - drop_info_t *drop_info; +ContinueHandleOlitTrigger(Display *dpy, unsigned char *data, unsigned long length, drop_info_t *drop_info) { CARD16 targets_index; Window psuedo_motif_initiator_win; @@ -1074,9 +1028,7 @@ ContinueHandleOlitTrigger(dpy, data, length, drop_info) /* Get OLIT initiator's TARGETS */ void -ProcessOlitInitiatorConversion(event, drop_info) - XSelectionEvent *event; - drop_info_t *drop_info; +ProcessOlitInitiatorConversion(XSelectionEvent *event, drop_info_t *drop_info) { Atom type; int format; @@ -1114,10 +1066,7 @@ ProcessOlitInitiatorConversion(event, drop_info) /* copy a property and the associated data from one window to another. Returns True if successful else returns False */ static int -CopyProperty(dpy, property, old_win, new_win) - Display *dpy; - Atom property; - Window old_win, new_win; +CopyProperty(Display *dpy, Atom property, Window old_win, Window new_win) { Atom type; int format; @@ -1147,10 +1096,7 @@ CopyProperty(dpy, property, old_win, new_win) from one window to another. Returns True if we get ATOM_SUN_DND_DONE or ATOM_SUN_SELECTION_END */ static int -CopyTargets(dpy, prop, old_win, new_win) - Display *dpy; - Atom prop; - Window old_win, new_win; +CopyTargets(Display *dpy, Atom prop, Window old_win, Window new_win) { Atom type; int format; @@ -1186,9 +1132,7 @@ CopyTargets(dpy, prop, old_win, new_win) /* Forward the SelectionNotify to the receiver. Returns True if we get ATOM_SUN_DND_DONE or ATOM_SUN_SELECTION_END */ static -ForwardConversion(event, drop_info) - XSelectionEvent *event; - drop_info_t *drop_info; +ForwardConversion(XSelectionEvent *event, drop_info_t *drop_info) { int ol_done = False; @@ -1254,9 +1198,7 @@ ForwardConversion(event, drop_info) the target data and places this info in a property on window A. */ void -ForwardMultpleSelectionRequest(event, drop_info) - XSelectionRequestEvent *event; - drop_info_t *drop_info; +ForwardMultpleSelectionRequest(XSelectionRequestEvent *event, drop_info_t *drop_info) { int format, status; unsigned long length, bytes_after; @@ -1285,10 +1227,7 @@ ForwardMultpleSelectionRequest(event, drop_info) /* tell the initiator to clean up and do internal cleanup */ void -DndDone(dpy, status, drop_info) - Display *dpy; - Atom status; - drop_info_t *drop_info; +DndDone(Display *dpy, Atom status, drop_info_t *drop_info) { XConvertSelection(dpy, drop_info->source_handle, @@ -1308,9 +1247,7 @@ DndDone(dpy, status, drop_info) } void -ProxyMain(dpy, event) - Display *dpy; - XEvent *event; +ProxyMain(Display *dpy, XEvent *event) { switch(event->type) { case ClientMessage: @@ -1478,7 +1415,7 @@ ProxyMain(dpy, event) (event->xselection.property == ATOM_SUN_DND_ACK)) { ProcessOlitInitiatorConversion(&event->xselection, drop_info); } else { - if (ForwardConversion(event, drop_info)) { + if (ForwardConversion(&event->xselection, drop_info)) { /* We are here ONLY if the target is ATOM_MULTIPLE and * the target list contains either _SUN_DRAGDROP_DONE or @@ -1490,3 +1427,4 @@ ProxyMain(dpy, event) } /* end of case SelectionNotify */ } /* end of switch */ } + -- 2.25.1