aboutsummaryrefslogtreecommitdiffstats
path: root/src/input
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-11 23:32:22 +0200
committerMax Kellermann <max@duempel.org>2009-10-11 23:32:22 +0200
commit727c301fbcd285ff781f2d9b538973ca6a4ebcef (patch)
treef75711b0035fdfb1e3a4f3e529ef5ffd9ef81d45 /src/input
parent71f881d5cb40fbb77a77a8b50b8d662acaa84310 (diff)
downloadmpd-727c301fbcd285ff781f2d9b538973ca6a4ebcef.tar.gz
mpd-727c301fbcd285ff781f2d9b538973ca6a4ebcef.tar.xz
mpd-727c301fbcd285ff781f2d9b538973ca6a4ebcef.zip
input_stream: use "goffset" instead of "off_t"
The "off_t" type may change when you enable or disable large file support on 32 bit platforms. This caused severe ABI problems within MPD when we enabled LFS for the first time: two sources included config.h and sys/types.h in different order, and had different off_t sizes - leading to memory corruption because of ABI incompatibility. This patch attempts to get rid of all public "off_t" uses: it removes "off_t" from the input_stream ABI/API, and switches to GLib's 64 bit "goffset" type. This may hurt 32 bit embedded platforms a tiny bit, but that's not even measurable.
Diffstat (limited to 'src/input')
-rw-r--r--src/input/curl_input_plugin.c16
-rw-r--r--src/input/file_input_plugin.c5
-rw-r--r--src/input/lastfm_input_plugin.c2
-rw-r--r--src/input/mms_input_plugin.c2
4 files changed, 13 insertions, 12 deletions
diff --git a/src/input/curl_input_plugin.c b/src/input/curl_input_plugin.c
index b83bcd918..2418f27bc 100644
--- a/src/input/curl_input_plugin.c
+++ b/src/input/curl_input_plugin.c
@@ -42,7 +42,7 @@
#define G_LOG_DOMAIN "input_curl"
/** rewinding is possible after up to 64 kB */
-static const off_t max_rewind_size = 64 * 1024;
+static const goffset max_rewind_size = 64 * 1024;
/**
* Buffers created by input_curl_writefunction().
@@ -425,7 +425,7 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size)
#ifndef NDEBUG
if (c->rewind != NULL &&
(!g_queue_is_empty(c->rewind) || is->offset == 0)) {
- off_t offset = 0;
+ goffset offset = 0;
struct buffer *buffer;
for (GList *list = g_queue_peek_head_link(c->rewind);
@@ -474,11 +474,11 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size)
if (icy_defined(&c->icy_metadata))
copy_icy_tag(c);
- is->offset += (off_t)nbytes;
+ is->offset += (goffset)nbytes;
#ifndef NDEBUG
if (rewind_buffers != NULL) {
- off_t offset = 0;
+ goffset offset = 0;
struct buffer *buffer;
for (GList *list = g_queue_peek_head_link(c->rewind);
@@ -772,7 +772,7 @@ input_curl_can_rewind(struct input_stream *is)
/* rewind is possible if this is the very first buffer of the
resource */
buffer = (struct buffer*)g_queue_peek_head(c->buffers);
- return (off_t)buffer->consumed == is->offset;
+ return (goffset)buffer->consumed == is->offset;
}
static void
@@ -780,7 +780,7 @@ input_curl_rewind(struct input_stream *is)
{
struct input_curl *c = is->data;
#ifndef NDEBUG
- off_t offset = 0;
+ goffset offset = 0;
#endif
assert(c->rewind != NULL);
@@ -818,7 +818,7 @@ input_curl_rewind(struct input_stream *is)
}
static bool
-input_curl_seek(struct input_stream *is, off_t offset, int whence)
+input_curl_seek(struct input_stream *is, goffset offset, int whence)
{
struct input_curl *c = is->data;
bool ret;
@@ -884,7 +884,7 @@ input_curl_seek(struct input_stream *is, off_t offset, int whence)
buffer = (struct buffer *)g_queue_pop_head(c->buffers);
length = buffer->size - buffer->consumed;
- if (offset - is->offset < (off_t)length)
+ if (offset - is->offset < (goffset)length)
length = offset - is->offset;
buffer = consume_buffer(buffer, length, rewind_buffers);
diff --git a/src/input/file_input_plugin.c b/src/input/file_input_plugin.c
index 64a4030ab..5dbbefcce 100644
--- a/src/input/file_input_plugin.c
+++ b/src/input/file_input_plugin.c
@@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "config.h" /* must be first for large file support */
#include "input/file_input_plugin.h"
#include "input_plugin.h"
@@ -92,11 +93,11 @@ input_file_open(struct input_stream *is, const char *filename)
}
static bool
-input_file_seek(struct input_stream *is, off_t offset, int whence)
+input_file_seek(struct input_stream *is, goffset offset, int whence)
{
int fd = GPOINTER_TO_INT(is->data);
- offset = lseek(fd, offset, whence);
+ offset = (goffset)lseek(fd, (off_t)offset, whence);
if (offset < 0) {
is->error = errno;
return false;
diff --git a/src/input/lastfm_input_plugin.c b/src/input/lastfm_input_plugin.c
index 4de62dc3b..4e13cd0ad 100644
--- a/src/input/lastfm_input_plugin.c
+++ b/src/input/lastfm_input_plugin.c
@@ -285,7 +285,7 @@ lastfm_input_eof_wrap(struct input_stream *is)
}
static bool
-lastfm_input_seek_wrap(struct input_stream *is, off_t offset, int whence)
+lastfm_input_seek_wrap(struct input_stream *is, goffset offset, int whence)
{
bool ret;
struct lastfm_input *d = is->data;
diff --git a/src/input/mms_input_plugin.c b/src/input/mms_input_plugin.c
index 2a3c53776..335571bef 100644
--- a/src/input/mms_input_plugin.c
+++ b/src/input/mms_input_plugin.c
@@ -110,7 +110,7 @@ input_mms_buffer(G_GNUC_UNUSED struct input_stream *is)
static bool
input_mms_seek(G_GNUC_UNUSED struct input_stream *is,
- G_GNUC_UNUSED off_t offset, G_GNUC_UNUSED int whence)
+ G_GNUC_UNUSED goffset offset, G_GNUC_UNUSED int whence)
{
return false;
}