From 207253b401e8b91ae2cd6147ccfa85b42bf78751 Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Wed, 22 Dec 2021 01:24:35 +0000 Subject: [PATCH] dtfile: Resolve uninitialized warnings --- cde/programs/dtfile/ChangeDirP.c | 2 +- cde/programs/dtfile/Directory.c | 18 ++++++++------ cde/programs/dtfile/File.c | 41 ++++++++++++++++++-------------- cde/programs/dtfile/FileDialog.c | 2 +- cde/programs/dtfile/FileOp.c | 6 ++--- cde/programs/dtfile/Find.c | 6 ++--- cde/programs/dtfile/IconWindow.c | 11 +++++---- cde/programs/dtfile/Main.c | 4 ++-- cde/programs/dtfile/OverWrite.c | 2 +- 9 files changed, 52 insertions(+), 40 deletions(-) diff --git a/cde/programs/dtfile/ChangeDirP.c b/cde/programs/dtfile/ChangeDirP.c index 412749907..e529ff23a 100644 --- a/cde/programs/dtfile/ChangeDirP.c +++ b/cde/programs/dtfile/ChangeDirP.c @@ -904,7 +904,7 @@ DrawCurrentDirectory( int draw_x; int draw_y; int dir_width; - int msg_width; + int msg_width = 0; short columns; Boolean msg_drawn; diff --git a/cde/programs/dtfile/Directory.c b/cde/programs/dtfile/Directory.c index 2f9fbb6c1..8f2d4f18c 100644 --- a/cde/programs/dtfile/Directory.c +++ b/cde/programs/dtfile/Directory.c @@ -1635,7 +1635,7 @@ ReadDirectoryProcess( position_count = 0; if ((fptr = fopen(file_name, "r")) != NULL) { - PositionInfo * position_info; + PositionInfo * position_info = NULL; fscanf(fptr, "%d\n", &position_count); if (position_count > 0) @@ -2142,7 +2142,7 @@ ReaddirPipeCallback( Boolean done; short msg; Boolean update_due; - FileData *new_data, **new_nextp; + FileData *new_data = NULL, **new_nextp; FileData *old_data, **old_nextp; char *ptr; char *err_msg; @@ -2285,7 +2285,9 @@ ReaddirPipeCallback( new_nextp = &(*new_nextp)->next) ; *new_nextp = new_data; - new_data->next = NULL; + if(new_data ) { + new_data->next = NULL; + } } if (activity == activity_reading) @@ -2814,7 +2816,7 @@ _ReadDir( { char subdir_name[MAX_PATH]; FileData *fp, *file_data; - FileViewData **lp, *ip; + FileViewData **lp = NULL, *ip; int i, j, n, rc; TreeShow ts; Boolean busy_reading; @@ -2894,7 +2896,7 @@ _ReadDir( } /* add new entry to linked list */ - if (dp) + if (dp && lp) { *lp = ip; lp = &ip->next; @@ -5130,7 +5132,7 @@ SelectDesktopFile( FileMgrData *file_mgr_data) { DirectorySet *directory_data; - FileViewData *file_view_data; + FileViewData *file_view_data = NULL; int j; directory_data = file_mgr_data->directory_set[0]; @@ -5149,5 +5151,7 @@ FileMgrData *file_mgr_data) } ActivateSingleSelect(file_mgr_data->file_mgr_rec, file_mgr_data->selection_list[0]->file_data->logical_type); - PositionFileView(file_view_data, file_mgr_data); + if(file_view_data) { + PositionFileView(file_view_data, file_mgr_data); + } } diff --git a/cde/programs/dtfile/File.c b/cde/programs/dtfile/File.c index 14b878676..87f0be00e 100644 --- a/cde/programs/dtfile/File.c +++ b/cde/programs/dtfile/File.c @@ -785,7 +785,7 @@ OrderFiles( FileViewData ** file_view_data; int file_count; FileViewData ** order_list; - int * sort; + int * sort = NULL; int * sub_sort; int i; int start; @@ -853,11 +853,14 @@ OrderFiles( else sort = (int *) FileSizeDescending; } - + else + { + /* Unknown sort order? */ + return; + } /* Sort the files and if the sub_sort function is non-null, */ /* sort sets of the files broken according to file type. */ - qsort (order_list, file_count, sizeof (FileViewData *), (int (*)())sort); if (sub_sort != NULL) @@ -3177,8 +3180,8 @@ CreateNameChangeDialog ( int type) { XRectangle textExtent; - FileMgrData * file_mgr_data; - DesktopRec * desktopWindow; + FileMgrData * file_mgr_data = NULL; + DesktopRec * desktopWindow = NULL; Widget parent = XtParent(w); Widget text; Arg args[8]; @@ -3317,18 +3320,20 @@ CreateNameChangeDialog ( else { text = XmCreateTextField(parent, "nameChangeT", args, n); - file_mgr_data->renaming = file_view_data; - XtAddCallback (text, XmNmotionVerifyCallback, - (XtCallbackProc)ChangeIconName, - (XtPointer)file_mgr_data); - XtAddCallback (text, XmNmodifyVerifyCallback, - (XtCallbackProc)ChangeIconName, - (XtPointer)file_mgr_data); - XtAddCallback (text, XmNactivateCallback, - (XtCallbackProc)ChangeIconName, - (XtPointer)file_mgr_data); - XtAddCallback(text, XmNhelpCallback, (XtCallbackProc)HelpRequestCB, - HELP_NAMECHANGE_DIALOG_STR); + if(file_mgr_data) { + file_mgr_data->renaming = file_view_data; + XtAddCallback(text, XmNmotionVerifyCallback, + (XtCallbackProc)ChangeIconName, + (XtPointer)file_mgr_data); + XtAddCallback(text, XmNmodifyVerifyCallback, + (XtCallbackProc)ChangeIconName, + (XtPointer)file_mgr_data); + XtAddCallback(text, XmNactivateCallback, + (XtCallbackProc)ChangeIconName, + (XtPointer)file_mgr_data); + XtAddCallback(text, XmNhelpCallback, (XtCallbackProc)HelpRequestCB, + HELP_NAMECHANGE_DIALOG_STR); + } } XtAddCallback (text, XmNdestroyCallback, DestroyIconName, (XtPointer)NULL); @@ -3425,7 +3430,7 @@ CreateNameChangeDialog ( XtManageChild(text); XmProcessTraversal(text, XmTRAVERSE_CURRENT); - if(type != DESKTOP) + if(type != DESKTOP && file_mgr_data) { FileMgrRec *file_mgr_rec; diff --git a/cde/programs/dtfile/FileDialog.c b/cde/programs/dtfile/FileDialog.c index 277bb55a4..497b03415 100644 --- a/cde/programs/dtfile/FileDialog.c +++ b/cde/programs/dtfile/FileDialog.c @@ -1482,7 +1482,7 @@ RenameOk( char to_host[256]; char to_dir[MAX_PATH]; char to_file[256]; - unsigned int modifiers; + unsigned int modifiers = 0; char *host_set[1], *file_set[1]; int file_count = 1; diff --git a/cde/programs/dtfile/FileOp.c b/cde/programs/dtfile/FileOp.c index 15823bedc..ff7f2b1ac 100644 --- a/cde/programs/dtfile/FileOp.c +++ b/cde/programs/dtfile/FileOp.c @@ -567,7 +567,7 @@ FileMoveCopyProcess( int mode, DesktopRec *desktopWindow) { - char * target_dir, * from, * to; + char * target_dir, * from = NULL, * to; int i, j, rc, result; Boolean return_val = False; Boolean isContainer; @@ -587,7 +587,7 @@ FileMoveCopyProcess( Boolean targetError = FALSE; Boolean CopyError=FALSE,MoveError1=FALSE,MoveError2=FALSE; char *CopyString=NULL,*MoveString1=NULL,*MoveString2=NULL; - Boolean Same; + Boolean Same = FALSE; /* Get the fully qualified destination path. */ target_dir = (char *)ResolveLocalPathName(host, directory, NULL, home_host_name, &tt_status); @@ -2489,7 +2489,7 @@ ChangeIconPipeCB( Widget msg_widget; DirectorySet *directory_set; FileMgrData *file_mgr_data = NULL; - FileMgrRec *file_mgr_rec; + FileMgrRec *file_mgr_rec = NULL; short pipe_msg; int i, j, n; int rc; diff --git a/cde/programs/dtfile/Find.c b/cde/programs/dtfile/Find.c index 067964f02..8688f500d 100644 --- a/cde/programs/dtfile/Find.c +++ b/cde/programs/dtfile/Find.c @@ -2107,7 +2107,7 @@ AlternateInputHandler( int offset = 0; char next; XmString string; - int count; + int count = 0; Arg args[1]; char * findptr; char * end; @@ -2260,7 +2260,7 @@ AlternateInputHandler2( FindRec * find_rec = (FindRec *) client_data; int offset = 0; char next; - int count; + int count = 0; char * findptr; struct stat stat_data; char * content; @@ -2381,7 +2381,7 @@ AlternateInputHandler3( int offset = 0; char next; XmString string; - int count; + int count = 0; Arg args[1]; char * findptr; struct stat stat_data; diff --git a/cde/programs/dtfile/IconWindow.c b/cde/programs/dtfile/IconWindow.c index a4bbeaf6c..cf3b70fb5 100644 --- a/cde/programs/dtfile/IconWindow.c +++ b/cde/programs/dtfile/IconWindow.c @@ -290,8 +290,8 @@ FileWindowInputCallback( DirectorySet * directoryData; XEvent *new_event; XButtonPressedEvent *event; - XKeyEvent *kevent; - Widget eventIcon; + XKeyEvent *kevent = NULL; + Widget eventIcon = NULL; int i, j; FileViewData * fileViewData = NULL; Arg args[10]; @@ -373,8 +373,11 @@ FileWindowInputCallback( /* get the gadget that received the input */ if (keybdFocusPolicy == XmEXPLICIT) eventIcon = (Widget) XmGetFocusWidget(w); - else - eventIcon = (Widget) InputForGadget(w, kevent->x, kevent->y); + else { + if(kevent) { + eventIcon = (Widget) InputForGadget(w, kevent->x, kevent->y); + } + } if (eventIcon == NULL) return; diff --git a/cde/programs/dtfile/Main.c b/cde/programs/dtfile/Main.c index 2460cebb7..e52f36c08 100644 --- a/cde/programs/dtfile/Main.c +++ b/cde/programs/dtfile/Main.c @@ -3219,7 +3219,7 @@ LoadViews ( static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL }; char view_number[11]; DialogData * dialog_data; - FileMgrData * file_mgr_data; + FileMgrData * file_mgr_data = NULL; char * workspaces; XClassHint classHints; char * iconify = NULL; @@ -3397,7 +3397,7 @@ LoadViews ( view_count++; } - if (openDirType == NEW) + if (openDirType == NEW && file_mgr_data) ForceMyIconOpen(file_mgr_data->host, NULL); } diff --git a/cde/programs/dtfile/OverWrite.c b/cde/programs/dtfile/OverWrite.c index 59fb7bbab..1026e62fe 100644 --- a/cde/programs/dtfile/OverWrite.c +++ b/cde/programs/dtfile/OverWrite.c @@ -312,7 +312,7 @@ buffer_replace_rename_ok_callback( XtPointer call_data) { int rc = 0; - String newFile, renameNewName, destinationName; + String newFile = NULL, renameNewName, destinationName; struct stat buf; int saveError = 0; static char msg[38+MAX_PATH];