1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

libdtterm: Resolve coverity issues

This commit is contained in:
Peter Howkins 2018-04-04 19:48:23 +01:00
parent 2d91ff7a6f
commit ccab0597ed
10 changed files with 26 additions and 23 deletions

View file

@ -1227,7 +1227,7 @@ Initialize(Widget ref_w, Widget w, Arg *args, Cardinal *num_args)
tpd->boldTermFont =
_DtTermPrimRenderFontCreate(w, tw->term.boldFont);
}
if (fontName) XFree(fontName) ;
XFree(fontName) ;
}
}
}
@ -1569,7 +1569,7 @@ InitOrResizeTermBuffer(Widget w)
** we ran out of memory, no need try and resize the
** term buffer
*/
resizeTermBuffer == False;
resizeTermBuffer = False;
}
}
@ -1893,7 +1893,6 @@ handleNonMaskableEvents(Widget w, XtPointer eventData, XEvent *event,
{
DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
DtTermPrimData tpd = tw->term.tpd;
unsigned char *buffer = (unsigned char *) 0;
int fd = tw->term.pty;
switch (event->type) {
@ -1926,11 +1925,6 @@ handleNonMaskableEvents(Widget w, XtPointer eventData, XEvent *event,
/* reinstall the pty input select... */
(void) _DtTermPrimStartOrStopPtyInput(w);
/* free the old buffer... */
if (buffer) {
(void) XtFree((char *) buffer);
}
if ((tpd->scroll.nojump.pendingScroll == 0) &&
!moreInput(tw->term.pty)) {
/* turn the cursor back on... */
@ -2306,6 +2300,7 @@ _mergeEnv
if (newEnv == NULL)
{
printf("L10n MALLOC ERROR\n");
return NULL;
}
/*
@ -3749,8 +3744,7 @@ _DtTermPrimPutEnv(char *c1, char *c2)
char buffer[BUFSIZ];
char *c;
(void) strcpy(buffer, c1);
(void) strcat(buffer, c2);
snprintf(buffer, sizeof(buffer), "%s%s", c1, c2);
c = XtMalloc(strlen(buffer) + 1);
(void) strcpy(c, buffer);
(void) putenv(c);

View file

@ -257,7 +257,7 @@ _countWidth
** its a null character, but is still has a width for our
** purposes...
*/
charWidth == 1;
charWidth = 1;
break;
default:
break;

View file

@ -283,8 +283,16 @@ SetupPty(char *ptySlave, int ptyFd)
#else /* linux */
chown(ptySlave, getuid(), getgid());
chmod(ptySlave, 0622);
if(chown(ptySlave, getuid(), getgid()) == -1) {
(void) perror("Error performing chown()");
/* exit the subprocess */
return(1);
}
if(chmod(ptySlave, 0622) == -1) {
(void) perror("Error performing chmod()");
/* exit the subprocess */
return(1);
}
#endif /* linux */
/* success... */

View file

@ -787,7 +787,7 @@ setSelection
selectColEnd = (selectInfo->end - 1) % (selectInfo->columns + 1);
DebugF('c', 1,
fprintf(stderr, "set selection units: %d-%d lines: %d-%d\n",
fprintf(stderr, "set selection units: %ld-%ld lines: %d-%d\n",
selectInfo->begin, selectInfo->end,
selectLineBegin,
selectLineEnd));
@ -2952,6 +2952,8 @@ _DtTermPrimSelectPasteClipboard
if (malloc_size != 0) XtFree(total_tmp_value);
(void) _DtTermPrimCursorOn(w);
return True;
}
/* This is the event interface for paste clipboard */

View file

@ -380,7 +380,6 @@ _DtTermPrimPtyGetDefaultModes()
/* we got a valid reference tty... */
DebugF('p', 3, fprintf(stderr,
">>_DtTermPrimPtyGetDefaultModes() valid reference \"/dev/tty\"\n"));
refTty = tty;
refValid = 1;
}
}

View file

@ -411,8 +411,8 @@ UtmpEntryCreate(Widget w, pid_t pid, char *utmpLine)
utPtr->ut_exit.e_exit = 2;
#endif
(void) strncpy(utPtr->ut_user, (userName && *userName) ? userName : "????",
sizeof(utPtr->ut_user));
snprintf(utPtr->ut_user, sizeof(utPtr->ut_user),
"%s", (userName && *userName) ? userName : "????");
(void) strncpy(utPtr->ut_line, utmpLine, sizeof(utPtr->ut_line));
utPtr->ut_pid = pid;
(void) time(&now);
@ -529,7 +529,7 @@ UtmpEntryDestroy(Widget w, char *utmpLine)
time_t now;
ut.ut_type = USER_PROCESS;
(void) strncpy(ut.ut_line, utmpLine, sizeof(ut.ut_line));
snprintf(ut.ut_line, sizeof(ut.ut_line), "%s", utmpLine);
(void) setutent();
if (utPtr = getutline(&ut)) {
utPtr->ut_type = DEAD_PROCESS;

View file

@ -620,7 +620,7 @@ _DtTermPrimLogFileCleanup
for (logInfoTmp = logInfoHead->next; logInfoTmp;
logInfoTmp = logInfoTmp->next) {
DebugF('s', 10, fprintf(stderr,
">>flushing logfile 0x%lx\n", logInfoTmp->logFile));
">>flushing logfile %p\n", logInfoTmp->logFile));
(void) fflush(logInfoTmp->logFile);
}
_DtTermProcessUnlock();

View file

@ -1696,7 +1696,7 @@ GeometryManager(Widget child, XtWidgetGeometry *desired,
c = "<unknown>";
}
(void) printf("GeometryManager: %s widget (0x%lx) requesting geo change\n",
(void) printf("GeometryManager: %s widget (%p) requesting geo change\n",
c, child);
return(XtGeometryNo);

View file

@ -367,7 +367,7 @@ createSizeMenu
}
/* get a mnemonic for "Default"... */
(void) strcpy(buffer, (GETMESSAGE(NL_SETN_ViewMenu,1, "Default")));
snprintf(buffer, sizeof(buffer), "%s", (GETMESSAGE(NL_SETN_ViewMenu,1, "Default")));
#ifdef NOTDEF
for (c2 = buffer; *c2; c2++) {
if (!strchr(mnemonics, *c2) && !isspace(*c2))
@ -575,7 +575,7 @@ createFontMenu
0, NULL, NULL, fontChangeCallback, (XtPointer) i1);
}
(void) strcpy(buffer, (GETMESSAGE(NL_SETN_ViewMenu,9, "Default")));
snprintf(buffer, sizeof(buffer), "%s", (GETMESSAGE(NL_SETN_ViewMenu,9, "Default")));
fontSizeToggles[i1] = _DtTermViewCreateToggleButton(submenu, buffer,
0, NULL, NULL, defaultFontCallback, NULL);
fontSizeTogglesDefault = i1;

View file

@ -131,7 +131,7 @@ char **argv;
}
/* back up buffer... */
(void) strncpy(orig, buffer, BUFSIZ);
(void) strncpy(orig, buffer, BUFSIZ - 1);
bufPtr = buffer;