dthelp: compiler warning and coverity warning fixes

This commit is contained in:
Peter Howkins
2018-03-29 00:21:44 +01:00
parent 50a96959f0
commit e12e009eb5
14 changed files with 68 additions and 34 deletions

View File

@@ -702,7 +702,7 @@ void Usage(void)
};
int i;
for (i=0; usage[i]; i++)
printf(_DTGETMESSAGE(INSET,i,usage[i]));
printf("%s", _DTGETMESSAGE(INSET,i,usage[i]));
} /*$END$*/
@@ -726,7 +726,7 @@ void CalculatePageSize(
char * appclass)
{ /*$CODE$*/
static struct unprintableMargins
struct unprintableMargins
{
int leftUnprintableMargin;
int rightUnprintableMargin;
@@ -744,7 +744,7 @@ void CalculatePageSize(
#define MAXVALIDSIZE 4
/* page size info */
static struct page
struct page
{
int width;
int height;
@@ -1469,10 +1469,10 @@ void _DtHPrGetResources(
if (debugHelpPrint)
{
if (*XtRefOffset(options,rsrc->resource_offset))
printf("options%s: %s\n", rsrc->resource_name,
*XtRefOffset(options,rsrc->resource_offset));
printf("options%s: %s\n", (char *) rsrc->resource_name,
(char *) *XtRefOffset(options,rsrc->resource_offset));
else
printf("options%s: <NULL>\n", rsrc->resource_name);
printf("options%s: <NULL>\n", (char *) rsrc->resource_name);
}
}
/* and calculate the page sizes */
@@ -1530,12 +1530,12 @@ char * _DtHPrCreateTmpFile(
newtmpfile=malloc((strlen(dirname) + FILENAMELEN + 2) * sizeof(char));
if (NULL == newtmpfile)
{
fprintf(stderr, _DTGETMESSAGE(INSET,45,
fprintf(stderr, "%s", _DTGETMESSAGE(INSET,45,
"Error: Unable to allocate memory for temporary file\n"));
}
else
{
sprintf(newtmpfile,_DTGETMESSAGE(INSET,50,"%1$s/%2$s%3$d_%4$d%5$s"),
sprintf(newtmpfile, _DTGETMESSAGE(INSET,50,"%1$s/%2$s%3$d_%4$d%5$s"),
dirname, prefix, getpid(), filecnt++, suffix );
}

View File

@@ -87,6 +87,7 @@ int _DtHPrPrintStringData(
char cmdFormat[100];
char prOffsetArg[30];
int status;
int retval;
if ( NULL == options->stringData )
{
@@ -120,7 +121,9 @@ int _DtHPrPrintStringData(
options->colsTextWidth, EMPTY_STR, /* fold */
options->topicTitle, options->rowsHeight, EMPTY_STR); /* pr */
return _DtHPrGenFileOrPrint(options,"String",printCommand);
retval = _DtHPrGenFileOrPrint(options,"String",printCommand);
free(printCommand);
return retval;
} /*$END$*/
@@ -144,6 +147,7 @@ int _DtHPrPrintDynamicStringData(
char cmdFormat[100];
char prOffsetArg[30];
int status;
int retval;
if ( NULL == options->stringData )
{
@@ -177,8 +181,9 @@ int _DtHPrPrintDynamicStringData(
options->colsTextWidth, EMPTY_STR, /* fold */
options->topicTitle, options->rowsHeight, EMPTY_STR); /* pr */
return _DtHPrGenFileOrPrint(options,"String",printCommand);
retval = _DtHPrGenFileOrPrint(options,"String",printCommand);
free(printCommand);
return retval;
} /*$END$*/
@@ -200,6 +205,7 @@ int _DtHPrPrintManPage(
char *printCommand;
char cmdFormat[100];
int status;
int retval;
if ( NULL == options->manPage )
{
@@ -223,13 +229,15 @@ int _DtHPrPrintManPage(
}
/** generate the command **/
sprintf(cmdFormat, "%s %s", /* man */
snprintf(cmdFormat, sizeof(cmdFormat), "%s %s", /* man */
options->manCommand, options->manArgs);
sprintf(printCommand, cmdFormat,
snprintf(printCommand, sizeof(MAX_COMMAND_LENGTH*sizeof(char)), cmdFormat,
options->manPage); /* man */
retval = _DtHPrGenFileOrPrint(options,options->manPage,printCommand);
free(printCommand);
return _DtHPrGenFileOrPrint(options,options->manPage,printCommand);
return retval;
} /*$END$*/
@@ -253,6 +261,7 @@ int _DtHPrPrintHelpFile(
char cmdFormat[100];
char prOffsetArg[30];
int status;
int retval;
if ( NULL == options->helpFile )
{
@@ -284,6 +293,8 @@ int _DtHPrPrintHelpFile(
options->colsTextWidth, options->helpFile, /* fold */
options->topicTitle, options->rowsHeight, EMPTY_STR); /* pr */
return _DtHPrGenFileOrPrint(options,options->helpFile,printCommand);
retval = _DtHPrGenFileOrPrint(options,options->helpFile,printCommand);
free(printCommand);
return retval;
} /*$END$*/

View File

@@ -1012,6 +1012,8 @@ int DoStrColsWidth(
wcstr[--wclen] = EOS;
wcstombs(str,wcstr,len+1);
free(wcstr);
return wclen;
} /*$END$*/
@@ -1091,6 +1093,9 @@ void GenHeadFootFormatArgs(
/* put into state data */
state->hffArgs.volumeDate = strdup(buf);
state->hffArgs.volumeDateColsWidth = width;
free(locDocId);
free(locDateStamp);
}
/* get today's date */
@@ -1749,6 +1754,8 @@ int ProcessSubTopics(
/* if processing subtopics, reset subsection number */
if(subSectNumIndex > 1) state->sectNums[subSectNumIndex] = 0;
state->level = level; /* state->level was modified by the FOR loop */
free(children);
return ret;
}

View File

@@ -204,7 +204,7 @@ int _DtHPrGenFileOrPrint(
}
/* put the shell print script in there */
sprintf(printCommand,"%s", options->shCommand,True);
sprintf(printCommand,"%s", options->shCommand);
/* set all the options that are IPC to the print script */
PutOpt(printCommand,OPT_LPDEST,options->printer,True);
@@ -221,7 +221,7 @@ int _DtHPrGenFileOrPrint(
/* unlink(tmpfile); ** NOTE: don't unlink; let the printCommand do it */
/* note the DTPRINTFILEREMOVE env var setting above */
free(tmpfile);
return(status);
} /*$END$*/