From: Adam Heath Date: Thu, 21 Dec 2000 07:43:22 +0000 (+0000) Subject: Switch all size parameters to ssize_t. Also, return totalread, not X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c78c24e34d17ca701522f35788669e93f0cbaad;p=dpkg Switch all size parameters to ssize_t. Also, return totalread, not bytesread, in buffer_copy. --- diff --git a/ChangeLog b/ChangeLog index 693e359b..e2686524 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Dec 21 01:40:02 CST 2000 Adam Heath + + * lib/mlib.c, include/dpkg.h.in: Switch all size parameters to + ssize_t. Also, return totalread, not bytesread, in buffer_copy. + Thu Dec 21 01:22:22 CST 2000 Adam Heath * lib/mlib.c: Handle EINTR on reading and writting in buffer_copy. diff --git a/include/dpkg.h.in b/include/dpkg.h.in index 7c9a0698..4d929922 100644 --- a/include/dpkg.h.in +++ b/include/dpkg.h.in @@ -206,7 +206,7 @@ void waitsubproc(pid_t pid, const char *description, int sigpipeok); #define BUFFER_READ_STREAM 1 typedef struct buffer_data *buffer_data_t; -typedef long (*buffer_proc_t)(buffer_data_t data, void *buf, long size, char *desc); +typedef ssize_t (*buffer_proc_t)(buffer_data_t data, void *buf, ssize_t size, char *desc); struct buffer_data { buffer_proc_t proc; void *data; @@ -243,10 +243,10 @@ struct buffer_data { buffer_copy_setup((void *)file, BUFFER_READ_STREAM, NULL, \ (void *)fd, BUFFER_WRITE_FD, NULL, \ limit, desc) -long buffer_copy_setup(void *argIn, int typeIn, void *procIn, +ssize_t buffer_copy_setup(void *argIn, int typeIn, void *procIn, void *argOut, int typeOut, void *procOut, - long limit, char *desc, ...); -long buffer_copy(buffer_data_t read_data, buffer_data_t write_data, long limit, char *desc); + ssize_t limit, char *desc, ...); +ssize_t buffer_copy(buffer_data_t read_data, buffer_data_t write_data, ssize_t limit, char *desc); extern volatile int onerr_abort; diff --git a/lib/mlib.c b/lib/mlib.c index 00886cf1..44b4faea 100644 --- a/lib/mlib.c +++ b/lib/mlib.c @@ -124,8 +124,8 @@ void waitsubproc(pid_t pid, const char *description, int sigpipeok) { checksubprocerr(status,description,sigpipeok); } -long buffer_write(buffer_data_t data, void *buf, long length, char *desc) { - long ret= length; +ssize_t buffer_write(buffer_data_t data, void *buf, ssize_t length, char *desc) { + ssize_t ret= length; switch(data->type) { case BUFFER_WRITE_BUF: memcpy(data->data, buf, length); @@ -153,8 +153,8 @@ long buffer_write(buffer_data_t data, void *buf, long length, char *desc) { return ret; } -long buffer_read(buffer_data_t data, void *buf, long length, char *desc) { - long ret= length; +ssize_t buffer_read(buffer_data_t data, void *buf, ssize_t length, char *desc) { + ssize_t ret= length; switch(data->type) { case BUFFER_READ_FD: if((ret= read((int)data->data, buf, length)) < 0 && errno != EINTR) @@ -173,15 +173,15 @@ long buffer_read(buffer_data_t data, void *buf, long length, char *desc) { return ret; } -long buffer_copy_setup(void *argIn, int typeIn, void *procIn, +ssize_t buffer_copy_setup(void *argIn, int typeIn, void *procIn, void *argOut, int typeOut, void *procOut, - long limit, char *desc, ...) + ssize_t limit, char *desc, ...) { struct buffer_data read_data = { procIn, argIn, typeIn }, write_data = { procOut, argOut, typeOut }; va_list al; struct varbuf v; - int ret; + ssize_t ret; varbufinit(&v); @@ -199,12 +199,11 @@ long buffer_copy_setup(void *argIn, int typeIn, void *procIn, } -long buffer_copy(buffer_data_t read_data, buffer_data_t write_data, long limit, char *desc) { +ssize_t buffer_copy(buffer_data_t read_data, buffer_data_t write_data, ssize_t limit, char *desc) { char *buf, *writebuf; long bytesread= 0, byteswritten= 0; int bufsize= 32768; - long totalread= 0; - long totalwritten= 0; + ssize_t totalread= 0, totalwritten= 0; if((limit != -1) && (limit < bufsize)) bufsize= limit; writebuf= buf= malloc(bufsize); if(buf== NULL) ohshite(_("failed to allocate buffer in buffer_copy (%s)"), desc); @@ -241,5 +240,5 @@ long buffer_copy(buffer_data_t read_data, buffer_data_t write_data, long limit, if (bytesread<0 || byteswritten<0) ohshite(_("failed in buffer_copy (%s)"), desc); free(buf); - return bytesread; + return totalread; } diff --git a/po/dpkg.pot b/po/dpkg.pot index c4c1baf1..3b727fa5 100644 --- a/po/dpkg.pot +++ b/po/dpkg.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-12-21 01:21-0600\n" +"POT-Creation-Date: 2000-12-21 01:36-0600\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -492,12 +492,12 @@ msgstr "" msgid "unknown data type `%i' in buffer_read\n" msgstr "" -#: lib/mlib.c:210 +#: lib/mlib.c:209 #, c-format msgid "failed to allocate buffer in buffer_copy (%s)" msgstr "" -#: lib/mlib.c:241 +#: lib/mlib.c:240 #, c-format msgid "failed in buffer_copy (%s)" msgstr ""