summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/rpmio.c24
-rw-r--r--rpmio/rpmio.h103
-rw-r--r--rpmio/rpmurl.h29
-rw-r--r--rpmio/url.c6
4 files changed, 104 insertions, 58 deletions
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index b9f143172..7e1bdd66a 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -1857,12 +1857,16 @@ int ufdClose( /*@only@*/ void * cookie)
} else {
int rc;
/* XXX STOR et al require close before ftpFileDone */
+ /*@-refcounttrans@*/
rc = fdClose(fd);
+ /*@=refcounttrans@*/
#if 0 /* XXX error exit from ufdOpen does not have this set */
assert(fd->ftpFileDoneNeeded != 0);
#endif
+ /*@-compdef@*/ /* FIX: u->data undefined */
if (fd->ftpFileDoneNeeded)
(void) ftpFileDone(u, fd);
+ /*@=compdef@*/
return rc;
}
}
@@ -1954,7 +1958,9 @@ fprintf(stderr, "-> \r\n");
exit:
if (uret)
*uret = u;
+ /*@-refcounttrans@*/
return fd;
+ /*@=refcounttrans@*/
}
/*@=nullstate@*/
@@ -1997,7 +2003,9 @@ static /*@null@*/ FD_t httpOpen(const char * url, /*@unused@*/ int flags,
exit:
if (uret)
*uret = u;
+ /*@-refcounttrans@*/
return fd;
+ /*@=refcounttrans@*/
}
/*@=nullstate@*/
@@ -2014,6 +2022,7 @@ static /*@null@*/ FD_t ufdOpen(const char * url, int flags, mode_t mode)
if (_rpmio_debug)
fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mode);
+ /*@-branchstate@*/
switch (urlType) {
case URL_IS_FTP:
fd = ftpOpen(url, flags, mode, &u);
@@ -2076,6 +2085,7 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mo
}
break;
}
+ /*@=branchstate@*/
if (fd == NULL) return NULL;
fd->urlType = urlType;
@@ -2324,8 +2334,10 @@ DBGIO(fd, (stderr, "==>\tgzdClose(%p) rc %lx %s\n", cookie, (unsigned long)rc, f
/*@=modfilesys@*/
if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "GZDIO", stderr);
+ /*@-branchstate@*/
if (rc == 0)
fd = fdFree(fd, "open (gzdClose)");
+ /*@=branchstate@*/
return rc;
}
@@ -2522,8 +2534,10 @@ DBGIO(fd, (stderr, "==>\tbzdClose(%p) rc %lx %s\n", cookie, (unsigned long)rc, f
/*@=modfilesys@*/
if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "BZDIO", stderr);
+ /*@-branchstate@*/
if (rc == 0)
fd = fdFree(fd, "open (bzdClose)");
+ /*@=branchstate@*/
return rc;
}
@@ -2575,7 +2589,7 @@ const char *Fstrerror(FD_t fd)
((fdGetIo(_fd) && fdGetIo(_fd)->_vec) ? fdGetIo(_fd)->_vec : NULL)
size_t Fread(void *buf, size_t size, size_t nmemb, FD_t fd) {
- fdio_read_function_t *_read;
+ fdio_read_function_t _read;
int rc;
FDSANE(fd);
@@ -2603,7 +2617,7 @@ DBGIO(fd, (stderr, "==> Fread(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigned
size_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd)
{
- fdio_write_function_t *_write;
+ fdio_write_function_t _write;
int rc;
FDSANE(fd);
@@ -2627,7 +2641,7 @@ DBGIO(fd, (stderr, "==> Fwrite(%p,%u,%u,%p) %s\n", buf, (unsigned)size, (unsigne
}
int Fseek(FD_t fd, _libio_off_t offset, int whence) {
- fdio_seek_function_t *_seek;
+ fdio_seek_function_t _seek;
#ifdef USE_COOKIE_SEEK_POINTER
_IO_off64_t o64 = offset;
_libio_pos_t pos = &o64;
@@ -2714,7 +2728,7 @@ DBGIO(fd, (stderr, "==> Fclose(%p) %s\n", (fd ? fd : NULL), fdbg(fd)));
}
} else {
/*@-nullderef@*/
- fdio_close_function_t * _close = FDIOVEC(fd, close);
+ fdio_close_function_t _close = FDIOVEC(fd, close);
/*@=nullderef@*/
rc = _close(fd);
}
@@ -2904,6 +2918,7 @@ DBGIO(fd, (stderr, "==> fopencookie(%p,\"%s\",*%p) returns fp %p\n", fd, stdio,
}
#endif
+ /*@-branchstate@*/
if (fp) {
/* XXX gzdio/bzdio use fp for private data */
/*@+voidabstract -nullpass@*/
@@ -2913,6 +2928,7 @@ DBGIO(fd, (stderr, "==> fopencookie(%p,\"%s\",*%p) returns fp %p\n", fd, stdio,
/*@=voidabstract =nullpass@*/
fd = fdLink(fd, "fopencookie");
}
+ /*@=branchstate@*/
}
/*@-modfilesys@*/
diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h
index 9c8a3016b..7069fdd99 100644
--- a/rpmio/rpmio.h
+++ b/rpmio/rpmio.h
@@ -57,39 +57,39 @@ extern "C" {
/**
*/
-typedef ssize_t fdio_read_function_t (void *cookie, char *buf, size_t nbytes)
+typedef ssize_t (*fdio_read_function_t) (void *cookie, char *buf, size_t nbytes)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
/**
*/
-typedef ssize_t fdio_write_function_t (void *cookie, const char *buf, size_t nbytes)
+typedef ssize_t (*fdio_write_function_t) (void *cookie, const char *buf, size_t nbytes)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
/**
*/
-typedef int fdio_seek_function_t (void *cookie, _libio_pos_t pos, int whence)
+typedef int (*fdio_seek_function_t) (void *cookie, _libio_pos_t pos, int whence)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
/**
*/
-typedef int fdio_close_function_t (void *cookie)
+typedef int (*fdio_close_function_t) (void *cookie)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
/**
*/
-typedef /*@only@*/ /*@null@*/ FD_t fdio_ref_function_t ( /*@only@*/ void * cookie,
+typedef /*@only@*/ /*@null@*/ FD_t (*fdio_ref_function_t) ( /*@only@*/ void * cookie,
const char * msg, const char * file, unsigned line)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef /*@only@*/ /*@null@*/ FD_t fdio_deref_function_t ( /*@only@*/ FD_t fd,
+typedef /*@only@*/ /*@null@*/ FD_t (*fdio_deref_function_t) ( /*@only@*/ FD_t fd,
const char * msg, const char * file, unsigned line)
/*@globals fileSystem @*/
/*@modifies fd, fileSystem @*/;
@@ -97,7 +97,7 @@ typedef /*@only@*/ /*@null@*/ FD_t fdio_deref_function_t ( /*@only@*/ FD_t fd,
/**
*/
-typedef /*@only@*/ /*@null@*/ FD_t fdio_new_function_t (const char * msg,
+typedef /*@only@*/ /*@null@*/ FD_t (*fdio_new_function_t) (const char * msg,
const char * file, unsigned line)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
@@ -105,32 +105,32 @@ typedef /*@only@*/ /*@null@*/ FD_t fdio_new_function_t (const char * msg,
/**
*/
-typedef int fdio_fileno_function_t (void * cookie)
+typedef int (*fdio_fileno_function_t) (void * cookie)
/*@globals fileSystem @*/
/*@modifies *cookie, fileSystem @*/;
/**
*/
-typedef FD_t fdio_open_function_t (const char * path, int flags, mode_t mode)
+typedef FD_t (*fdio_open_function_t) (const char * path, int flags, mode_t mode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef FD_t fdio_fopen_function_t (const char * path, const char * fmode)
+typedef FD_t (*fdio_fopen_function_t) (const char * path, const char * fmode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef void * fdio_ffileno_function_t (FD_t fd)
+typedef void * (*fdio_ffileno_function_t) (FD_t fd)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef int fdio_fflush_function_t (FD_t fd)
+typedef int (*fdio_fflush_function_t) (FD_t fd)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@}*/
@@ -143,50 +143,50 @@ typedef int fdio_fflush_function_t (FD_t fd)
/**
*/
-typedef int fdio_mkdir_function_t (const char * path, mode_t mode)
+typedef int (*fdio_mkdir_function_t) (const char * path, mode_t mode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef int fdio_chdir_function_t (const char * path)
+typedef int (*fdio_chdir_function_t) (const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef int fdio_rmdir_function_t (const char * path)
+typedef int (*fdio_rmdir_function_t) (const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef int fdio_rename_function_t (const char * oldpath, const char * newpath)
+typedef int (*fdio_rename_function_t) (const char * oldpath, const char * newpath)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/**
*/
-typedef int fdio_unlink_function_t (const char * path)
+typedef int (*fdio_unlink_function_t) (const char * path)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@-typeuse@*/
/**
*/
-typedef int fdio_stat_function_t (const char * path, /*@out@*/ struct stat * st)
+typedef int (*fdio_stat_function_t) (const char * path, /*@out@*/ struct stat * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
/**
*/
-typedef int fdio_lstat_function_t (const char * path, /*@out@*/ struct stat * st)
+typedef int (*fdio_lstat_function_t) (const char * path, /*@out@*/ struct stat * st)
/*@globals fileSystem @*/
/*@modifies *st, fileSystem @*/;
/**
*/
-typedef int fdio_access_function_t (const char * path, int amode)
+typedef int (*fdio_access_function_t) (const char * path, int amode)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
/*@=typeuse@*/
@@ -196,26 +196,26 @@ typedef int fdio_access_function_t (const char * path, int amode)
/** \ingroup rpmio
*/
struct FDIO_s {
- fdio_read_function_t * read;
- fdio_write_function_t * write;
- fdio_seek_function_t * seek;
- fdio_close_function_t * close;
-
- fdio_ref_function_t * _fdref;
- fdio_deref_function_t * _fdderef;
- fdio_new_function_t * _fdnew;
- fdio_fileno_function_t * _fileno;
-
- fdio_open_function_t * _open;
- fdio_fopen_function_t * _fopen;
- fdio_ffileno_function_t * _ffileno;
- fdio_fflush_function_t * _fflush;
-
- fdio_mkdir_function_t * _mkdir;
- fdio_chdir_function_t * _chdir;
- fdio_rmdir_function_t * _rmdir;
- fdio_rename_function_t * _rename;
- fdio_unlink_function_t * _unlink;
+ fdio_read_function_t read;
+ fdio_write_function_t write;
+ fdio_seek_function_t seek;
+ fdio_close_function_t close;
+
+ fdio_ref_function_t _fdref;
+ fdio_deref_function_t _fdderef;
+ fdio_new_function_t _fdnew;
+ fdio_fileno_function_t _fileno;
+
+ fdio_open_function_t _open;
+ fdio_fopen_function_t _fopen;
+ fdio_ffileno_function_t _ffileno;
+ fdio_fflush_function_t _fflush;
+
+ fdio_mkdir_function_t _mkdir;
+ fdio_chdir_function_t _chdir;
+ fdio_rmdir_function_t _rmdir;
+ fdio_rename_function_t _rename;
+ fdio_unlink_function_t _unlink;
};
@@ -482,11 +482,30 @@ int fdClose( /*@only@*/ void * cookie)
#define fdCLose(_fd) fdio->close(_fd)
/**
- * FD_t reference count debugging wrappers.
- * @todo Remove debugging entries from the ABI.
*/
+/*@unused@*/
+/*@only@*/ /*@null@*/
+FD_t fdLink (/*@only@*/ void * cookie, const char * msg)
+ /*@globals fileSystem @*/
+ /*@modifies *cookie, fileSystem @*/;
#define fdLink(_fd, _msg) fdio->_fdref(_fd, _msg, __FILE__, __LINE__)
+
+/**
+ */
+/*@unused@*/
+/*@only@*/ /*@null@*/
+FD_t fdFree(/*@only@*/ FD_t fd, const char * msg)
+ /*@globals fileSystem @*/
+ /*@modifies fd, fileSystem @*/;
#define fdFree(_fd, _msg) fdio->_fdderef(_fd, _msg, __FILE__, __LINE__)
+
+/**
+ */
+/*@unused@*/
+/*@only@*/ /*@null@*/
+FD_t fdNew (const char * msg)
+ /*@globals fileSystem @*/
+ /*@modifies fileSystem @*/;
#define fdNew(_msg) fdio->_fdnew(_msg, __FILE__, __LINE__)
/**
diff --git a/rpmio/rpmurl.h b/rpmio/rpmurl.h
index 3c3e66a8f..b555d59f4 100644
--- a/rpmio/rpmurl.h
+++ b/rpmio/rpmurl.h
@@ -21,19 +21,28 @@ typedef enum urltype_e {
#define URLMAGIC 0xd00b1ed0
#define URLSANE(u) assert(u && u->magic == URLMAGIC)
+typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s * urlinfo;
/**
* URL control structure.
*/
-typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s {
+struct urlinfo_s {
/*@refs@*/ int nrefs; /*!< no. of references */
-/*@owned@*/ /*@null@*/ const char * url; /*!< copy of original url */
-/*@owned@*/ /*@null@*/ const char * service;
-/*@owned@*/ /*@null@*/ const char * user;
-/*@owned@*/ /*@null@*/ const char * password;
-/*@owned@*/ /*@null@*/ const char * host;
-/*@owned@*/ /*@null@*/ const char * portstr;
-/*@owned@*/ /*@null@*/ const char * proxyu; /*!< FTP: proxy user */
-/*@owned@*/ /*@null@*/ const char * proxyh; /*!< FTP/HTTP: proxy host */
+/*@owned@*/ /*@null@*/
+ const char * url; /*!< copy of original url */
+/*@owned@*/ /*@null@*/
+ const char * service;
+/*@owned@*/ /*@null@*/
+ const char * user;
+/*@owned@*/ /*@null@*/
+ const char * password;
+/*@owned@*/ /*@null@*/
+ const char * host;
+/*@owned@*/ /*@null@*/
+ const char * portstr;
+/*@owned@*/ /*@null@*/
+ const char * proxyu; /*!< FTP: proxy user */
+/*@owned@*/ /*@null@*/
+ const char * proxyh; /*!< FTP/HTTP: proxy host */
int proxyp; /*!< FTP/HTTP: proxy port */
int port;
int urltype;
@@ -45,7 +54,7 @@ typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo_s {
int httpVersion;
int httpHasRange;
int magic;
-} * urlinfo;
+};
#ifdef __cplusplus
extern "C" {
diff --git a/rpmio/url.c b/rpmio/url.c
index fb280d026..cadfee67a 100644
--- a/rpmio/url.c
+++ b/rpmio/url.c
@@ -93,6 +93,8 @@ urlinfo XurlNew(const char *msg, const char *file, unsigned line)
urlinfo XurlFree(urlinfo u, const char *msg, const char *file, unsigned line)
{
+ int xx;
+
URLSANE(u);
URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file, line));
if (--u->nrefs > 0)
@@ -105,7 +107,7 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
fdPush(u->ctrl, fpio, fp, -1); /* Push fpio onto stack */
(void) Fclose(u->ctrl);
} else if (fdio->_fileno(u->ctrl) >= 0)
- fdio->close(u->ctrl);
+ xx = fdio->close(u->ctrl);
/*@=branchstate@*/
#else
(void) Fclose(u->ctrl);
@@ -126,7 +128,7 @@ URLDBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file,
fdPush(u->data, fpio, fp, -1); /* Push fpio onto stack */
(void) Fclose(u->data);
} else if (fdio->_fileno(u->data) >= 0)
- fdio->close(u->data);
+ xx = fdio->close(u->data);
#else
(void) Fclose(u->ctrl);
#endif