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

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

@ -341,7 +341,7 @@ CreateVolumeLink (
* put the abstract information about this * put the abstract information about this
* family in the header file * family in the header file
*/ */
fprintf (outTopic, GetMessage (3, 3, "<P before 1 first 1 left 1>\n")); fprintf (outTopic, "%s", GetMessage (3, 3, "<P before 1 first 1 left 1>\n"));
if (abstract != NULL) if (abstract != NULL)
{ {
@ -489,7 +489,7 @@ CreateFamily (
*/ */
fprintf (out_topic, (GetMessage (3, 2, (char*)defaultTitle14)), fprintf (out_topic, (GetMessage (3, 2, (char*)defaultTitle14)),
title); title);
fprintf (out_topic, (GetMessage (3, 3, "<P before 1 first 1 left 1>\n"))); fprintf (out_topic, "%s", (GetMessage (3, 3, "<P before 1 first 1 left 1>\n")));
fprintf (out_topic, "%s\n", abstract); fprintf (out_topic, "%s\n", abstract);
fprintf (out_topic, "</P>\n"); fprintf (out_topic, "</P>\n");
@ -549,7 +549,7 @@ CreateFamily (
bitmap, familyName); bitmap, familyName);
} }
else else
fprintf (out_header, GetMessage (3, 3, "<P before 1 first 1 left 1>\n")); fprintf (out_header, "%s", GetMessage (3, 3, "<P before 1 first 1 left 1>\n"));
fprintf (out_header, "%s\n", abstract); fprintf (out_header, "%s\n", abstract);
fprintf (out_header, "</P></CHARACTERSET>\n"); fprintf (out_header, "</P></CHARACTERSET>\n");
@ -579,6 +579,8 @@ CreateFamily (
} }
XrmDestroyDatabase (db); XrmDestroyDatabase (db);
} }
free (token);
return result; return result;
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -24,6 +24,8 @@
/* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */ /* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
/* Miscellaneous Procedures for HP Tag/TeX translator */ /* Miscellaneous Procedures for HP Tag/TeX translator */
#include <stdint.h>
#include "userinc.h" #include "userinc.h"
#include "globdec.h" #include "globdec.h"
@ -307,7 +309,7 @@ while (TRUE)
node[n] = current->next; node[n] = current->next;
if (! id[n]) if (! id[n])
{ {
if ((int) current->data >= 0) if ((intptr_t) current->data >= 0)
m_err1("No glossary definition for %s", id); m_err1("No glossary definition for %s", id);
current = current->next; current = current->next;
while (! current) while (! current)
@ -2194,13 +2196,13 @@ if (vgloss(gloss) == GLOSS)
*(termp-1) = M_EOS; *(termp-1) = M_EOS;
} }
idn = (int) m_lookfortrie(base ? base : dterm, &gtree); idn = (intptr_t) m_lookfortrie(base ? base : dterm, &gtree);
if (idn < 0) if (idn < 0)
idn = -idn; idn = -idn;
if (!idn) if (!idn)
{ {
idn = NextId(); idn = NextId();
m_ntrtrie(base ? base : dterm, &gtree, (void *) idn); m_ntrtrie(base ? base : dterm, &gtree, (void *) (intptr_t) idn);
} }
} }

View file

@ -241,4 +241,4 @@
248, "fraction 1/2", UNSUPP, NULL, 0, 248, "fraction 1/2", UNSUPP, NULL, 0,
251, "French double open quote", UNSUPP, NULL, 0, 251, "French double open quote", UNSUPP, NULL, 0,
252, "Solid square", UNSUPP, NULL, 0, 252, "Solid square", UNSUPP, NULL, 0,
253, "French double close quote", UNSUPP, NULL, NULL 253, "French double close quote", UNSUPP, NULL, 0

View file

@ -24,6 +24,8 @@
/* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */ /* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
/* Miscellaneous Procedures for HP Tag/TeX translator */ /* Miscellaneous Procedures for HP Tag/TeX translator */
#include <stdint.h>
#include "userinc.h" #include "userinc.h"
#include "globdec.h" #include "globdec.h"
@ -306,7 +308,7 @@ while (TRUE)
node[n] = current->next; node[n] = current->next;
if (! id[n]) if (! id[n])
{ {
if ((int) current->data >= 0) if ((intptr_t) current->data >= 0)
m_err1("No glossary definition for %s", id); m_err1("No glossary definition for %s", id);
current = current->next; current = current->next;
while (! current) while (! current)
@ -1612,6 +1614,8 @@ else
} }
_DtLcxCloseDb(&myDb); _DtLcxCloseDb(&myDb);
free(charset);
free(lang);
} }
@ -2192,13 +2196,13 @@ if (vgloss(gloss) == GLOSS)
*(termp-1) = M_EOS; *(termp-1) = M_EOS;
} }
idn = (int) m_lookfortrie(base ? base : dterm, &gtree); idn = (intptr_t) m_lookfortrie(base ? base : dterm, &gtree);
if (idn < 0) if (idn < 0)
idn = -idn; idn = -idn;
if (!idn) if (!idn)
{ {
idn = NextId(); idn = NextId();
m_ntrtrie(base ? base : dterm, &gtree, (void *) idn); m_ntrtrie(base ? base : dterm, &gtree, (void *) (intptr_t) idn);
} }
} }

View file

@ -155,7 +155,10 @@ strcpy(helpext, ".xrh");
tex = fopen(helpbase, "w"); tex = fopen(helpbase, "w");
fprintf(tex, "\\gobble\001%s\002%%\n", m_signon); fprintf(tex, "\\gobble\001%s\002%%\n", m_signon);
fputs("% Generated Cross-Reference Macros (for a particular document)\n", tex); fputs("% Generated Cross-Reference Macros (for a particular document)\n", tex);
if (! xtree.data) return; if (! xtree.data) {
fclose(tex);
return;
}
n = 0; n = 0;
current = xtree.data; current = xtree.data;

View file

@ -544,6 +544,8 @@ void srefout(M_NOPAR)
fputs(ndif, dtd) ; fputs(ndif, dtd) ;
} }
SUBONE SUBONE
free(mapbysref);
} }
/* Output one element block in a template */ /* Output one element block in a template */

View file

@ -231,7 +231,7 @@ SEARCH *searchp;
char *mb_entcontent; char *mb_entcontent;
mb_entcontent = MakeMByteString(entcontent); mb_entcontent = MakeMByteString(entcontent);
if (!*mb_entcontent) return NULL; /* null file name, don't open a directory */ if (!mb_entcontent || !*mb_entcontent) return NULL; /* null file name, don't open a directory */
open = fopen(mb_entcontent, "r"); open = fopen(mb_entcontent, "r");
if (open) if (open)

View file

@ -424,8 +424,12 @@ if (loading) newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *));
if (! newtransit || (loading && ! newdlm)) if (! newtransit || (loading && ! newdlm))
{ {
trysize = NUMDELIM + 1; trysize = NUMDELIM + 1;
free(newtransit);
newtransit = (int *) calloc(NUMCON * trysize, sizeof(int)); newtransit = (int *) calloc(NUMCON * trysize, sizeof(int));
if (loading) newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *)); if (loading) {
free(newdlm);
newdlm = (char **) calloc(trysize, sizeof(M_WCHAR *));
}
} }
if (! newtransit || (loading && ! newdlm)) if (! newtransit || (loading && ! newdlm))
{ {

View file

@ -144,6 +144,7 @@ void copyfile(pfile1,pfile2)
ret = system(pcmd); ret = system(pcmd);
ret = snprintf(pcmd, slen, "touch %s",pfile2); ret = snprintf(pcmd, slen, "touch %s",pfile2);
ret = system(pcmd); ret = system(pcmd);
free(pcmd);
} }
int nextchar(file, data) int nextchar(file, data)

View file

@ -84,16 +84,13 @@ void *m_wctrace(
#endif #endif
) ; ) ;
void m_free(block, msg) void m_free(void *block, char *msg)
void *block ;
char *msg ;
{ {
char buffer[32] ; char buffer[32] ;
#if defined(MSDOS) #if defined(MSDOS)
if (m_heapchk) m_heapdump() ; if (m_heapchk) m_heapdump() ;
#endif #endif
free(block) ;
if (m_malftrace) { if (m_malftrace) {
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__) #if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__)
snprintf(buffer, 32, "%5x:%5x", snprintf(buffer, 32, "%5x:%5x",
@ -107,6 +104,7 @@ void m_free(block, msg)
m_trace(msg) ; m_trace(msg) ;
m_trace("\n") ; m_trace("\n") ;
} }
free(block) ;
#if defined(MSDOS) #if defined(MSDOS)
if (m_heapchk) m_heapdump() ; if (m_heapchk) m_heapdump() ;
#endif #endif