src/fccache.c (FcGlobalCacheLoad, FcGlobalCacheSave, FcDirCacheConsume,
FcDirCacheWrite) Check I/O call return values and eliminate unused variable warnings. reviewed by: plam
This commit is contained in:
parent
c4c47a7654
commit
68355f3877
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2006-02-03 Takashi IWAI <tiwai@suse.de>
|
||||||
|
reviewed by: plam
|
||||||
|
|
||||||
|
* fc-cat/fc-cat.c (FcCacheGlobalFileReadAndPrint, main,
|
||||||
|
FcCacheFileRead):
|
||||||
|
|
||||||
|
* src/fccache.c (FcGlobalCacheLoad, FcGlobalCacheSave,
|
||||||
|
FcDirCacheConsume, FcDirCacheWrite)
|
||||||
|
* src/fcxml.c (FcConfigMessage):
|
||||||
|
|
||||||
|
Check I/O call return values and eliminate unused variable
|
||||||
|
warnings.
|
||||||
|
|
||||||
2006-02-03 Takashi Iwai <tiwai@suse.de>
|
2006-02-03 Takashi Iwai <tiwai@suse.de>
|
||||||
reviewed by: plam
|
reviewed by: plam
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,7 @@ FcCacheGlobalFileReadAndPrint (FcFontSet * set, FcStrSet *dirs, char *cache_file
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
char * dir, * ls;
|
char * dir;
|
||||||
FcCacheReadString (fd, name_buf, sizeof (name_buf));
|
FcCacheReadString (fd, name_buf, sizeof (name_buf));
|
||||||
if (!strlen(name_buf))
|
if (!strlen(name_buf))
|
||||||
break;
|
break;
|
||||||
|
@ -241,7 +241,6 @@ FcCacheFileRead (FcFontSet * set, FcStrSet *dirs, char *cache_file)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char * current_arch_machine_name;
|
char * current_arch_machine_name;
|
||||||
char candidate_arch_machine_name[9+MACHINE_SIGNATURE_SIZE];
|
|
||||||
off_t current_arch_start = 0;
|
off_t current_arch_start = 0;
|
||||||
char subdirName[FC_MAX_FILE_LEN + 1 + 12 + 1];
|
char subdirName[FC_MAX_FILE_LEN + 1 + 12 + 1];
|
||||||
static char name_buf[8192], *dir;
|
static char name_buf[8192], *dir;
|
||||||
|
@ -411,7 +410,7 @@ main (int argc, char **argv)
|
||||||
if (i >= argc)
|
if (i >= argc)
|
||||||
usage (argv[0]);
|
usage (argv[0]);
|
||||||
|
|
||||||
if (name_buf = FcCacheFileRead (fs, dirs, argv[i]))
|
if ((name_buf = FcCacheFileRead (fs, dirs, argv[i])) != 0)
|
||||||
FcCachePrintSet (fs, dirs, name_buf);
|
FcCachePrintSet (fs, dirs, name_buf);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -251,11 +251,20 @@ FcGlobalCacheLoad (FcGlobalCache *cache,
|
||||||
(config_time.set && cache_stat.st_mtime < config_time.time))
|
(config_time.set && cache_stat.st_mtime < config_time.time))
|
||||||
{
|
{
|
||||||
FcCache md;
|
FcCache md;
|
||||||
|
off_t off;
|
||||||
|
|
||||||
FcStrSetAdd (staleDirs, FcStrCopy ((FcChar8 *)name_buf));
|
FcStrSetAdd (staleDirs, FcStrCopy ((FcChar8 *)name_buf));
|
||||||
read (cache->fd, &md, sizeof (FcCache));
|
if (read (cache->fd, &md, sizeof (FcCache)) != sizeof(FcCache))
|
||||||
lseek (cache->fd, FcCacheNextOffset (lseek(cache->fd, 0, SEEK_CUR)) + md.count, SEEK_SET);
|
{
|
||||||
continue;
|
perror ("read metadata");
|
||||||
|
goto bail1;
|
||||||
|
}
|
||||||
|
off = FcCacheNextOffset (lseek(cache->fd, 0, SEEK_CUR)) + md.count;
|
||||||
|
if (lseek (cache->fd, off, SEEK_SET) != off) {
|
||||||
|
perror ("lseek");
|
||||||
|
goto bail1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
d = malloc (sizeof (FcGlobalCacheDir));
|
d = malloc (sizeof (FcGlobalCacheDir));
|
||||||
|
@ -465,21 +474,38 @@ FcGlobalCacheSave (FcGlobalCache *cache,
|
||||||
|
|
||||||
for (dir = cache->dirs; dir; dir = dir->next)
|
for (dir = cache->dirs; dir; dir = dir->next)
|
||||||
{
|
{
|
||||||
if (dir->name)
|
if (dir->name)
|
||||||
{
|
{
|
||||||
const char * d = (const char *)FcConfigNormalizeFontDir (config, (const FcChar8 *)dir->name);
|
const char * d = (const char *)FcConfigNormalizeFontDir (config, (const FcChar8 *)dir->name);
|
||||||
|
off_t off;
|
||||||
|
|
||||||
FcCacheWriteString (fd, d);
|
FcCacheWriteString (fd, d);
|
||||||
|
|
||||||
for (i = 0; i < dir->subdirs->size; i++)
|
for (i = 0; i < dir->subdirs->size; i++)
|
||||||
FcCacheWriteString (fd, (char *)dir->subdirs->strs[i]);
|
FcCacheWriteString (fd, (char *)dir->subdirs->strs[i]);
|
||||||
FcCacheWriteString (fd, "");
|
FcCacheWriteString (fd, "");
|
||||||
|
|
||||||
write (fd, &dir->metadata, sizeof(FcCache));
|
if (write (fd, &dir->metadata, sizeof(FcCache)) != sizeof(FcCache))
|
||||||
lseek (fd, FcCacheNextOffset (lseek(fd, 0, SEEK_CUR)), SEEK_SET);
|
{
|
||||||
write (fd, dir->ent, dir->metadata.count);
|
perror ("write metadata");
|
||||||
free (dir->ent);
|
free (dir->ent);
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
off = FcCacheNextOffset (lseek(fd, 0, SEEK_CUR));
|
||||||
|
if (lseek (fd, off, SEEK_SET) != off)
|
||||||
|
{
|
||||||
|
perror ("lseek");
|
||||||
|
free (dir->ent);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (write (fd, dir->ent, dir->metadata.count) != dir->metadata.count)
|
||||||
|
{
|
||||||
|
perror ("write dirent");
|
||||||
|
free (dir->ent);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
free (dir->ent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FcCacheWriteString (fd, "");
|
FcCacheWriteString (fd, "");
|
||||||
|
|
||||||
|
@ -1025,7 +1051,8 @@ FcDirCacheConsume (int fd, const char * dir, FcFontSet *set, FcConfig *config)
|
||||||
void * current_dir_block;
|
void * current_dir_block;
|
||||||
off_t pos;
|
off_t pos;
|
||||||
|
|
||||||
read(fd, &metadata, sizeof(FcCache));
|
if (read(fd, &metadata, sizeof(FcCache)) != sizeof(FcCache))
|
||||||
|
return FcFalse;
|
||||||
if (metadata.magic != FC_CACHE_MAGIC)
|
if (metadata.magic != FC_CACHE_MAGIC)
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
|
|
||||||
|
@ -1238,11 +1265,18 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
|
||||||
FcCacheWriteString (fd, (char *)dirs->strs[i]);
|
FcCacheWriteString (fd, (char *)dirs->strs[i]);
|
||||||
FcCacheWriteString (fd, "");
|
FcCacheWriteString (fd, "");
|
||||||
|
|
||||||
write (fd, &metadata, sizeof(FcCache));
|
if (write (fd, &metadata, sizeof(FcCache)) != sizeof(FcCache)) {
|
||||||
|
perror("write metadata");
|
||||||
|
goto bail5;
|
||||||
|
}
|
||||||
if (metadata.count)
|
if (metadata.count)
|
||||||
{
|
{
|
||||||
lseek (fd, FcCacheNextOffset (lseek(fd, 0, SEEK_END)), SEEK_SET);
|
off_t off = FcCacheNextOffset (lseek(fd, 0, SEEK_END));
|
||||||
write (fd, current_dir_block, metadata.count);
|
if (lseek (fd, off, SEEK_SET) != off)
|
||||||
|
perror("lseek");
|
||||||
|
else if (write (fd, current_dir_block, metadata.count) !=
|
||||||
|
metadata.count)
|
||||||
|
perror("write current_dir_block");
|
||||||
free (current_dir_block);
|
free (current_dir_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -493,10 +493,10 @@ FcConfigMessage (FcConfigParse *parse, FcConfigSeverity severe, const char *fmt,
|
||||||
{
|
{
|
||||||
if (parse->name)
|
if (parse->name)
|
||||||
fprintf (stderr, "Fontconfig %s: \"%s\", line %d: ", s,
|
fprintf (stderr, "Fontconfig %s: \"%s\", line %d: ", s,
|
||||||
parse->name, XML_GetCurrentLineNumber (parse->parser));
|
parse->name, (int)XML_GetCurrentLineNumber (parse->parser));
|
||||||
else
|
else
|
||||||
fprintf (stderr, "Fontconfig %s: line %d: ", s,
|
fprintf (stderr, "Fontconfig %s: line %d: ", s,
|
||||||
XML_GetCurrentLineNumber (parse->parser));
|
(int)XML_GetCurrentLineNumber (parse->parser));
|
||||||
if (severe >= FcSevereError)
|
if (severe >= FcSevereError)
|
||||||
parse->error = FcTrue;
|
parse->error = FcTrue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue