[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pdf-devel] pdf-fsys-disk.c: fpos_t VS size_t
From: |
Changhua Yang |
Subject: |
[pdf-devel] pdf-fsys-disk.c: fpos_t VS size_t |
Date: |
Wed, 31 Mar 2010 22:48:14 +0800 |
Hi,
I got abnormal output file with size bigger than 1.5 TB. Debugging found
the reason is failure calls of fsetpos.
pdf_status_t
pdf_fsys_disk_file_set_pos (pdf_fsys_file_t file,
pdf_size_t new_pos)
{
if(file != NULL)
{
return
((fsetpos(((pdf_fsys_disk_file_t)file->data)->file_descriptor, \
(fpos_t*)&new_pos) == 0) ?
\
PDF_OK :
\
__pdf_fsys_disk_get_status_from_errno(errno));
}
else
{
return PDF_EBADDATA;
}
}
In my system _FILE_OFFSET_BITS is defined 64. The system call set the
errno to 22, invalid arguments.
Changing code like this fixed the problem:
pdf_status_t
pdf_fsys_disk_file_set_pos (pdf_fsys_file_t file,
pdf_size_t new_pos)
{
if(file != NULL)
{
printf("sizeof fpos_t=%d\n", sizeof(fpos_t));
fpos_t fnew_pos ;
fnew_pos.__pos = new_pos;
return
((fsetpos(((pdf_fsys_disk_file_t)file->data)->file_descriptor, \
(fpos_t*)&fnew_pos) == 0) ?
\
PDF_OK :
\
__pdf_fsys_disk_get_status_from_errno(errno));
}
else
{
return PDF_EBADDATA;
}
}
Also the same in pdf_fsys_disk_file_get_pos.
The definition of fpos_t is something like:
22 typedef struct
23 {
24 __off_t __pos;
25 __mbstate_t __state;
26 } _G_fpos_t;
27 typedef struct
28 {
29 __off64_t __pos;
30 __mbstate_t __state;
31 } _G_fpos64_t;
I'm not sure is it necessary to init __state member. I get a network
problem to connect to google.com and google.cn just has been closed.:(
Please check the code.
- [pdf-devel] pdf-fsys-disk.c: fpos_t VS size_t,
Changhua Yang <=