1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

common/iobuf.c: Remove dead code (directfp).

* common/iobuf.h (struct iobuf_struct): Remove field directfp.  Remove
all uses of it.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
This commit is contained in:
Neal H. Walfield 2015-08-09 16:50:42 +02:00
parent f05d60b381
commit e8c0b6abf8
2 changed files with 1 additions and 65 deletions

View File

@ -1129,15 +1129,6 @@ iobuf_close (iobuf_t a)
size_t dummy_len = 0;
int rc = 0;
if (a && a->directfp)
{
fclose (a->directfp);
xfree (a->real_fname);
if (DBG_IOBUF)
log_debug ("iobuf_close -> %p\n", a->directfp);
return 0;
}
for (; a && !rc; a = a2)
{
a2 = a->chain;
@ -1614,9 +1605,6 @@ iobuf_push_filter2 (iobuf_t a,
size_t dummy_len = 0;
int rc = 0;
if (a->directfp)
BUG ();
if (a->use == IOBUF_OUTPUT && (rc = iobuf_flush (a)))
return rc;
@ -1701,9 +1689,6 @@ pop_filter (iobuf_t a, int (*f) (void *opaque, int control,
size_t dummy_len = 0;
int rc = 0;
if (a->directfp)
BUG ();
if (DBG_IOBUF)
log_debug ("iobuf-%d.%d: pop '%s'\n", a->no, a->subno,
a->desc?a->desc:"?");
@ -1814,22 +1799,6 @@ underflow (iobuf_t a)
return -1;
}
if (a->directfp)
{
FILE *fp = a->directfp;
len = fread (a->d.buf, 1, a->d.size, fp);
if (len < a->d.size)
{
if (ferror (fp))
a->error = gpg_error_from_syserror ();
}
a->d.len = len;
a->d.start = 0;
return len ? a->d.buf[a->d.start++] : -1;
}
if (a->filter)
{
len = a->d.size;
@ -1904,9 +1873,6 @@ iobuf_flush (iobuf_t a)
size_t len;
int rc;
if (a->directfp)
return 0;
if (a->use == IOBUF_TEMP)
{ /* increase the temp buffer */
unsigned char *newbuf;
@ -2057,9 +2023,6 @@ iobuf_writebyte (iobuf_t a, unsigned int c)
{
int rc;
if (a->directfp)
BUG ();
if (a->d.len == a->d.size)
if ((rc=iobuf_flush (a)))
return rc;
@ -2076,9 +2039,6 @@ iobuf_write (iobuf_t a, const void *buffer, unsigned int buflen)
const unsigned char *buf = (const unsigned char *)buffer;
int rc;
if (a->directfp)
BUG ();
do
{
if (buflen && a->d.len < a->d.size)
@ -2185,16 +2145,6 @@ iobuf_get_filelength (iobuf_t a, int *overflow)
if (overflow)
*overflow = 0;
if ( a->directfp )
{
FILE *fp = a->directfp;
if ( !fstat(fileno(fp), &st) )
return st.st_size;
log_error("fstat() failed: %s\n", strerror(errno) );
return 0;
}
/* Hmmm: file_filter may have already been removed */
for ( ; a; a = a->chain )
if ( !a->chain && a->filter == file_filter )
@ -2262,9 +2212,6 @@ iobuf_get_filelength (iobuf_t a, int *overflow)
int
iobuf_get_fd (iobuf_t a)
{
if (a->directfp)
return fileno ( (FILE*)a->directfp );
for ( ; a; a = a->chain )
if (!a->chain && a->filter == file_filter)
{
@ -2328,17 +2275,7 @@ iobuf_seek (iobuf_t a, off_t newpos)
{
file_filter_ctx_t *b = NULL;
if (a->directfp)
{
FILE *fp = a->directfp;
if (fseeko (fp, newpos, SEEK_SET))
{
log_error ("can't seek: %s\n", strerror (errno));
return -1;
}
clearerr (fp);
}
else if (a->use != IOBUF_TEMP)
if (a->use != IOBUF_TEMP)
{
for (; a; a = a->chain)
{

View File

@ -76,7 +76,6 @@ struct iobuf_struct
off_t nbytes; /* Used together with nlimit. */
off_t ntotal; /* Total bytes read (position of stream). */
int nofast; /* Used by the iobuf_get (). */
void *directfp;
struct
{
size_t size; /* Allocated size */