dtcudcfonted: Resolve compiler and coverity warnings

This commit is contained in:
Peter Howkins
2018-03-28 01:29:28 +01:00
parent 49d1ca38e4
commit 55c59be795
16 changed files with 127 additions and 115 deletions

View File

@@ -623,6 +623,7 @@ store_to_database(db)
if(new->name){
Xfree(new->name);
}
Xfree(new);
}
if(parse_info.value){
if(*parse_info.value){

View File

@@ -457,8 +457,8 @@ XLCdGenericPart *gen;
_fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
dbg_printValue(name,value,num);
if (num > 0) {
strcpy(cset_name,value[0]);
sprintf(name, "%s.%s", csd , "side");
snprintf(cset_name, sizeof(cset_name), "%s", value[0]);
snprintf(name, sizeof(name), "%s.%s", csd , "side");
_fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
dbg_printValue(name,value,num);
@@ -495,21 +495,21 @@ XLCdGenericPart *gen;
/* side */
charsetd->side = side ;
/* length */
sprintf(name, "%s.%s", csd , "length");
snprintf(name, sizeof(name), "%s.%s", csd , "length");
_fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
dbg_printValue(name,value,num);
charsetd->char_size = atoi(value[0]);
}
/* gc_number */
sprintf(name, "%s.%s", csd , "gc_number");
snprintf(name, sizeof(name), "%s.%s", csd , "gc_number");
_fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
dbg_printValue(name,value,num);
charsetd->set_size = atoi(value[0]);
}
/* string_encoding */
sprintf(name, "%s.%s", csd , "string_encoding");
snprintf(name, sizeof(name), "%s.%s", csd , "string_encoding");
_fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
dbg_printValue(name,value,num);
@@ -520,7 +520,7 @@ XLCdGenericPart *gen;
}
}
/* sequence */
sprintf(name, "%s.%s", csd , "sequence");
snprintf(name, sizeof(name), "%s.%s", csd , "sequence");
_fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
dbg_printValue(name,value,num);
@@ -537,7 +537,7 @@ XLCdGenericPart *gen;
string_to_encoding(value[0],tmp);
}
/* encoding_name */
sprintf(name, "%s.%s", csd , "encoding_name");
snprintf(name, sizeof(name), "%s.%s", csd , "encoding_name");
_fallcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
dbg_printValue(name,value,num);
@@ -698,6 +698,7 @@ int num;
if(strchr(value[0],':')){
ret->name = (char *)Xmalloc(strlen(value[0])+1);
if(ret->name == NULL){
XFree(ret);
return(NULL);
}
strcpy(ret->name,value[0]);
@@ -706,24 +707,27 @@ int num;
ptr++;
if( !_fallcNCompareISOLatin1(ptr, "none", 4) ){
ret->side = XlcNONE ;
sprintf(cset_name,"%s:%s",ret->name,"none");
snprintf(cset_name,sizeof(cset_name),"%s:%s",ret->name,"none");
} else
if( !_fallcNCompareISOLatin1(ptr, "GL", 2) ){
ret->side = XlcGL ;
sprintf(cset_name,"%s:%s",ret->name,"GL");
snprintf(cset_name,sizeof(cset_name),"%s:%s",ret->name,"GL");
} else {
ret->side = XlcGR ;
sprintf(cset_name,"%s:%s",ret->name,"GR");
snprintf(cset_name,sizeof(cset_name),"%s:%s",ret->name,"GR");
}
} else {
ret->name = (char *)Xmalloc(strlen(value[0])+1);
if(ret->name == NULL){
XFree(ret);
return(NULL);
}
strcpy(ret->name,value[0]);
}
ret->area = (FontScope)Xmalloc((num - 1)*sizeof(FontScopeRec));
if(ret->area == NULL){
XFree(ret->name);
XFree(ret);
return(NULL);
}
ret->area_num = num - 1;
@@ -735,7 +739,10 @@ int num;
if(new){
tmp = (char *)Xmalloc(strlen(cset_name)+1);
if(tmp == NULL){
return 0;
XFree(ret->area);
XFree(ret->name);
XFree(ret);
return NULL;
}
strcpy(tmp,cset_name);
ret->charset->name = tmp;

View File

@@ -79,6 +79,7 @@ from the X Consortium.
* Katsuhisa Yano TOSHIBA Corp.
*/
#include <stdint.h>
#include "_fallibint.h"
#include "_fallcint.h"
#if defined(linux)
@@ -499,12 +500,12 @@ _fallcCopyFromArg(src, dst, size)
*((long *) dst) = (long) src;
#ifdef LONG64
else if (size == sizeof(int))
*((int *) dst) = (int) src;
*((int *) dst) = (int) (intptr_t) src;
#endif
else if (size == sizeof(short))
*((short *) dst) = (short) src;
*((short *) dst) = (short) (intptr_t) src;
else if (size == sizeof(char))
*((char *) dst) = (char) src;
*((char *) dst) = (char) (intptr_t) src;
else if (size == sizeof(XPointer))
*((XPointer *) dst) = (XPointer) src;
else if (size > sizeof(XPointer))

View File

@@ -625,19 +625,20 @@ static char
}
}
if(field_num < CHARSET_ENCODING_FIELD)
if(field_num < CHARSET_ENCODING_FIELD) {
Xfree(pattern);
return NULL;
}
/* Pixel Size field : fields[6] */
for(ptr = fields[PIXEL_SIZE_FIELD - 1] ; ptr && *ptr; ptr++) {
if(!isdigit(*ptr)) {
if(pattern)
Xfree(pattern);
Xfree(pattern);
return NULL;
}
}
pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]);
sprintf(str_pixel, "[ 0 ~%d %d 0 ]", pixel_size, pixel_size);
snprintf(str_pixel, sizeof(str_pixel), "[ 0 ~%d %d 0 ]", pixel_size, pixel_size);
fields[6] = str_pixel;
/* Point Size field : fields[7] */
@@ -647,7 +648,7 @@ static char
rotate_font[0] = '\0';
for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD &&
fields[field_num] ; field_num++) {
sprintf(rotate_font, "%s-%s", rotate_font, fields[field_num]);
snprintf(rotate_font, sizeof(rotate_font), "%s-%s", rotate_font, fields[field_num]);
}
if(pattern)
@@ -713,7 +714,6 @@ parse_omit_name(oc, font_data, pattern)
if(is_match_charset(font_data, pattern) == True) {
strcpy(buf, pattern);
length = strlen(pattern);
if (font_name = get_font_name(oc, buf)) {
font_data->xlfd_name = (char *)Xmalloc(strlen(font_name) + 1);
if(font_data->xlfd_name == NULL) {
@@ -1674,8 +1674,10 @@ char **value;
bufptr++ ;
}
font_data->name = (char *) Xmalloc(len + 1);
if (font_data->name == NULL)
if (font_data->name == NULL) {
XFree(font_data);
return NULL;
}
strncpy(font_data->name, buf,len);
font_data->name[len] = 0;
if (bufptr && _fallcCompareISOLatin1(bufptr, "GL") == 0)
@@ -1726,7 +1728,7 @@ int num;
char **value, buf[BUFSIZ], *bufptr;
int count,i;
sprintf(buf, "fs%d.font.vertical_map", num);
snprintf(buf, sizeof(buf), "fs%d.font.vertical_map", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count > 0){
dbg_printValue(buf,value,count);
@@ -1734,7 +1736,7 @@ int num;
font_set->vmap = falread_EncodingInfo(count,value);
}
sprintf(buf, "fs%d.font.vertical_rotate", num);
snprintf(buf, sizeof(buf), "fs%d.font.vertical_rotate", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count > 0){
dbg_printValue(buf,value,count);
@@ -1771,11 +1773,11 @@ init_om(om)
for (num = 0; ; num++) {
sprintf(buf, "fs%d.charset.name", num);
snprintf(buf, sizeof(buf), "fs%d.charset.name", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if( count < 1){
sprintf(buf, "fs%d.charset", num);
snprintf(buf, sizeof(buf), "fs%d.charset", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1)
break;
@@ -1794,7 +1796,7 @@ init_om(om)
while (count-- > 0){
*charset_list++ = _fallcGetCharSet(*value++);
}
sprintf(buf, "fs%d.charset.udc_area", num);
snprintf(buf, sizeof(buf), "fs%d.charset.udc_area", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if( count > 0){
UDCArea udc;
@@ -1817,10 +1819,10 @@ init_om(om)
}
}
sprintf(buf, "fs%d.font.primary", num);
snprintf(buf, sizeof(buf), "fs%d.font.primary", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1){
sprintf(buf, "fs%d.font", num);
snprintf(buf, sizeof(buf), "fs%d.font", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1)
return False;
@@ -1833,7 +1835,7 @@ init_om(om)
data->font_data = font_data;
data->font_data_count = count;
sprintf(buf, "fs%d.font.substitute", num);
snprintf(buf, sizeof(buf), "fs%d.font.substitute", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count > 0){
font_data = falread_EncodingInfo(count,value);
@@ -1842,7 +1844,7 @@ init_om(om)
data->substitute = font_data;
data->substitute_num = count;
} else {
sprintf(buf, "fs%d.font", num);
snprintf(buf, sizeof(buf), "fs%d.font", num);
_fallcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1) {
data->substitute = NULL;

View File

@@ -32,6 +32,7 @@
*
*/
#include <stdio.h>
#include <stdint.h>
#include <locale.h>
#include "syncx.h"
#include "_fallibint.h"
@@ -410,7 +411,7 @@ unsigned long *codepoint;
memset(dst,0,25);
lcd = (XLCd)_fallcGenericLoader(locale);
lcd = (XLCd) (uintptr_t) _fallcGenericLoader(locale);
fal_gi_to_vgi(lcd,locale,charset_str,codeset,
glyph_index,&glyph_index,charsetname);
@@ -439,9 +440,9 @@ unsigned long *codepoint;
if( falnon_standard(lcd,charset)) {
falmake_none_standard(from,charset,src);
} else if(charset->ct_sequence){
sprintf((char *)from,"%s%s",charset->ct_sequence,src);
snprintf((char *)from, sizeof(from32), "%s%s", charset->ct_sequence,src);
} else {
sprintf((char *)from,"%s\0",src);
snprintf((char *)from, sizeof(from32), "%s", src);
}
/* compound text -> multi byte */
conv = _fallcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte);
@@ -640,7 +641,7 @@ int *num_gi;
dst = (unsigned char *)to32;
memset(dst,0,25);
lcd = (XLCd)_fallcGenericLoader(locale);
lcd = (XLCd) (uintptr_t) _fallcGenericLoader(locale);
for(i=0,j=0;i<4;i++){
byte = getbyte(codepoint,i);
@@ -650,7 +651,7 @@ int *num_gi;
}
}
src[j] = 0;
sprintf((char *)from,"%s\0",src);
snprintf((char *)from, sizeof(from32), "%s", src);
/* multi byte -> vgi */
conv = _fallcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet);
from_left = strlen((char *)from);
@@ -674,13 +675,14 @@ int *num_gi;
_fallcDestroyLC(lcd);
*gi = (FalGIInf *)Xmalloc(sizeof(FalGIInf));
(*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1);
strcpy((*gi)->charset_str,charsetname);
(*gi)->glyph_index = glyph;
if(*gi == NULL){
fal_utyerrno = 0x03 ;
return(FAL_ERROR);
}
(*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1);
strcpy((*gi)->charset_str,charsetname);
(*gi)->glyph_index = glyph;
*num_gi = 1;
return(0);
}

View File

@@ -343,6 +343,10 @@ int lockflag;
if ( !(finf->fname = (char *)strdup( openfontfile )) ) {
fal_seterrcode( _FAL_MALOC_ER, 0,
FAL_ERR_MALLOC , FAL_FUNCNUM_OPNFNT ) ;
free( openfontfile );
free( finf );
free( buf );
close( fd );
return (FalFontID)FAL_ERROR;
}
@@ -501,9 +505,7 @@ int lockflag;
}
set_errfile_str( fal_err_file_buf, finf->fname ) ;
if ( finf->fname ) {
free( finf->fname );
}
free( finf->fname );
if ( finf->buf != NULL ) {
#if defined( SVR4 )
if ( finf->ismmap == TRUE ) {
@@ -520,15 +522,10 @@ int lockflag;
close( finf->fd );
#endif
if ( finf->sptnBuf ) {
free( finf->sptnBuf );
}
if ( finf->dptnBuf ){
free( finf->dptnBuf );
}
if ( finf->dbuf ) {
free( finf->dbuf );
}
free( finf->sptnBuf );
free( finf->dptnBuf );
free( finf->dbuf );
free ( finf );
}
if ( lockflag == 1 ) {
@@ -1069,15 +1066,9 @@ FalFontDataList *list;
if ( list->list != NULL ) {
for ( i = 0; i < list->num; i++ ) {
/* free a structure's character of "FalFontData()" */
if ( list->list[i].xlfdname ) {
free( list->list[i].xlfdname );
}
if ( list->list[i].style.name ) {
free( list->list[i].style.name );
}
if ( list->list[i].shape.name ) {
free( list->list[i].shape.name );
}
free( list->list[i].xlfdname );
free( list->list[i].style.name );
free( list->list[i].shape.name );
FAL_FREE_FONTLIST_OPTION( list ) ;
}
/* free a structure's array of "FalFontData()" */
@@ -1143,15 +1134,9 @@ fal_clear_data(tmp)
FalFontData *tmp;
{
/* search a character */
if ( tmp->xlfdname != NULL ) {
free(tmp->xlfdname);
}
if (tmp->style.name != NULL) {
free(tmp->style.name);
}
if (tmp->shape.name != NULL) {
free(tmp->shape.name);
}
free(tmp->xlfdname);
free(tmp->style.name);
free(tmp->shape.name);
FAL_CLEAR_DATA_OPTION( tmp ) ;
memset(tmp, 0, sizeof(*tmp));
return 0 ;
@@ -2296,6 +2281,7 @@ FalFontPath *pathlist ;
fal_clear_font_path( pathlist );
fal_utyerror = _FAL_MALOC_ER;
fal_utyerrno = FAL_ERR_MALLOC ;
free(path);
return FAL_ERROR ;
}
pathlist->path = plist;
@@ -2982,6 +2968,7 @@ int islock ;
if( (flist[cnt] = (FontIDInfo *)malloc( sizeof(FontIDInfo) )) == NULL ) {
fal_utyerror = _FAL_MALOC_ER ;
fal_utyerrno = FAL_ERR_MALLOC ;
free(flist);
return FAL_ERROR ;
}
flist[cnt]->fid = fid ;

View File

@@ -778,7 +778,7 @@ char *propname;
if ( *buffer) { /* isStringProp */
return( propstr + getINT32( (unsigned char *)(buffer + 1), (CARD32)format) );
}else{
return((char *)getINT32( (unsigned char *)(buffer + 1), (CARD32)format) );
return((char *)(intptr_t)getINT32( (unsigned char *)(buffer + 1), (CARD32)format) );
}
}
buffer += 5 ; /* isStringProp + value */
@@ -800,7 +800,7 @@ FalFontData *databuff ;
caddr_t stprop ;
int lb, rb, as, ds ;
char *propptr ;
char *fnt, *fam ;
char *fnt = NULL, *fam ;
int nprops, bitmapSize, num_chars ;
@@ -863,6 +863,7 @@ FalFontData *databuff ;
return 0;
Bail:
free(fnt);
return -1;
}
@@ -890,7 +891,7 @@ char *propname;
if( ProcRec->indirect ){
return( propstr + ProcRec->value ) ;
}else{
return( (char *)ProcRec->value ) ;
return( (char *) (intptr_t) ProcRec->value ) ;
}
}
}