Explorar o código

libdpkg: Remove unused proc member from buffer_data

Guillem Jover %!s(int64=17) %!d(string=hai) anos
pai
achega
0f7c88fe1c
Modificáronse 2 ficheiros con 55 adicións e 66 borrados
  1. 9 16
      lib/dpkg/buffer.c
  2. 46 50
      lib/dpkg/buffer.h

+ 9 - 16
lib/dpkg/buffer.c

@@ -161,19 +161,14 @@ buffer_read(buffer_data_t data, void *buf, off_t length, const char *desc)
 }
 
 off_t
-buffer_copy_setup(buffer_arg argIn, int typeIn, void *procIn,
-                  buffer_arg argOut, int typeOut, void *procOut,
+buffer_copy_setup(buffer_arg argIn, int typeIn,
+                  buffer_arg argOut, int typeOut,
                   off_t limit, const char *desc)
 {
-	struct buffer_data read_data = { procIn, argIn, typeIn },
-	                   write_data = { procOut, argOut, typeOut };
+	struct buffer_data read_data = { argIn, typeIn },
+	                   write_data = { argOut, typeOut };
 	off_t ret;
 
-	if (procIn == NULL)
-		read_data.proc = buffer_read;
-	if (procOut == NULL)
-		write_data.proc = buffer_write;
-
 	buffer_init(&read_data, &write_data);
 	ret = buffer_copy(&read_data, &write_data, limit, desc);
 	buffer_done(&read_data, &write_data);
@@ -184,8 +179,8 @@ buffer_copy_setup(buffer_arg argIn, int typeIn, void *procIn,
 
 #define buffer_copy_setup_dual(name, type1, name1, type2, name2) \
 off_t \
-buffer_copy_setup_##name(type1 n1, int typeIn, void *procIn, \
-                         type2 n2, int typeOut, void *procOut, \
+buffer_copy_setup_##name(type1 n1, int typeIn, \
+                         type2 n2, int typeOut, \
                          off_t limit, const char *desc, ...) \
 { \
 	va_list al; \
@@ -199,9 +194,7 @@ buffer_copy_setup_##name(type1 n1, int typeIn, void *procIn, \
 	varbufvprintf(&v, desc, al); \
 	va_end(al); \
 \
-	ret = buffer_copy_setup(a1, typeIn, procIn, \
-	                        a2, typeOut, procOut, \
-	                        limit, v.buf); \
+	ret = buffer_copy_setup(a1, typeIn, a2, typeOut, limit, v.buf); \
 	varbuffree(&v); \
 \
 	return ret; \
@@ -229,7 +222,7 @@ buffer_copy(buffer_data_t read_data, buffer_data_t write_data,
 	writebuf = buf = m_malloc(bufsize);
 
 	while (bytesread >= 0 && byteswritten >= 0 && bufsize > 0) {
-		bytesread = read_data->proc(read_data, buf, bufsize, desc);
+		bytesread = buffer_read(read_data, buf, bufsize, desc);
 		if (bytesread < 0) {
 			if (errno == EINTR || errno == EAGAIN)
 				continue;
@@ -246,7 +239,7 @@ buffer_copy(buffer_data_t read_data, buffer_data_t write_data,
 		}
 		writebuf = buf;
 		while (bytesread) {
-			byteswritten = write_data->proc(write_data, writebuf, bytesread, desc);
+			byteswritten = buffer_write(write_data, writebuf, bytesread, desc);
 			if (byteswritten == -1) {
 				if (errno == EINTR || errno == EAGAIN)
 					continue;

+ 46 - 50
lib/dpkg/buffer.h

@@ -43,122 +43,118 @@ DPKG_BEGIN_DECLS
 
 typedef struct buffer_data *buffer_data_t;
 
-typedef off_t (*buffer_proc_t)(buffer_data_t data, void *buf, off_t size,
-                               const char *desc);
-
 typedef union buffer_arg {
 	void *ptr;
 	int i;
 } buffer_arg;
 
 struct buffer_data {
-	buffer_proc_t proc;
 	buffer_arg data;
 	int type;
 };
 
 #if HAVE_C99
 # define fd_md5(fd, hash, limit, ...) \
-	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-	                         hash, BUFFER_WRITE_MD5, NULL, \
+	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+	                         hash, BUFFER_WRITE_MD5, \
 	                         limit, __VA_ARGS__)
 # define stream_md5(file, hash, limit, ...) \
-	buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
-	                         hash, BUFFER_WRITE_MD5, NULL, \
+	buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, \
+	                         hash, BUFFER_WRITE_MD5, \
 	                         limit, __VA_ARGS__)
 # define fd_fd_copy(fd1, fd2, limit, ...) \
-	buffer_copy_setup_IntInt(fd1, BUFFER_READ_FD, NULL, \
-	                         fd2, BUFFER_WRITE_FD, NULL, \
+	buffer_copy_setup_IntInt(fd1, BUFFER_READ_FD, \
+	                         fd2, BUFFER_WRITE_FD, \
 	                         limit, __VA_ARGS__)
 # define fd_buf_copy(fd, buf, limit, ...) \
-	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-	                         buf, BUFFER_WRITE_BUF, NULL, \
+	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+	                         buf, BUFFER_WRITE_BUF, \
 	                         limit, __VA_ARGS__)
 # define fd_vbuf_copy(fd, buf, limit, ...) \
-	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-	                         buf, BUFFER_WRITE_VBUF, NULL, \
+	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+	                         buf, BUFFER_WRITE_VBUF, \
 	                         limit, __VA_ARGS__)
 # define fd_null_copy(fd, limit, ...) \
 	if (lseek(fd, limit, SEEK_CUR) == -1) { \
 		if (errno != ESPIPE) \
 			ohshite(__VA_ARGS__); \
-		buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-		                         NULL, BUFFER_WRITE_NULL, NULL, \
+		buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+		                         NULL, BUFFER_WRITE_NULL, \
 		                         limit, __VA_ARGS__); \
 	}
 # define stream_null_copy(file, limit, ...) \
 	if (fseek(file, limit, SEEK_CUR) == -1) { \
 		if (errno != EBADF) \
 			ohshite(__VA_ARGS__); \
-		buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
-		                         NULL, BUFFER_WRITE_NULL, NULL, \
+		buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, \
+		                         NULL, BUFFER_WRITE_NULL, \
 		                         limit, __VA_ARGS__); \
 	}
 # define stream_fd_copy(file, fd, limit, ...) \
-	buffer_copy_setup_PtrInt(file, BUFFER_READ_STREAM, NULL, \
-	                         fd, BUFFER_WRITE_FD, NULL, \
+	buffer_copy_setup_PtrInt(file, BUFFER_READ_STREAM, \
+	                         fd, BUFFER_WRITE_FD, \
 	                         limit, __VA_ARGS__)
 #else /* HAVE_C99 */
 # define fd_md5(fd, hash, limit, desc...) \
-	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-	                         hash, BUFFER_WRITE_MD5, NULL, \
+	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+	                         hash, BUFFER_WRITE_MD5, \
 	                         limit, desc)
 # define stream_md5(file, hash, limit, desc...) \
-	buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
-	                         hash, BUFFER_WRITE_MD5, NULL, \
+	buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, \
+	                         hash, BUFFER_WRITE_MD5, \
 	                         limit, desc)
 # define fd_fd_copy(fd1, fd2, limit, desc...) \
-	buffer_copy_setup_IntInt(fd1, BUFFER_READ_FD, NULL, \
-	                         fd2, BUFFER_WRITE_FD, NULL, \
+	buffer_copy_setup_IntInt(fd1, BUFFER_READ_FD, \
+	                         fd2, BUFFER_WRITE_FD, \
 	                         limit, desc)
 # define fd_buf_copy(fd, buf, limit, desc...) \
-	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-	                         buf, BUFFER_WRITE_BUF, NULL, \
+	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+	                         buf, BUFFER_WRITE_BUF, \
 	                         limit, desc)
 # define fd_vbuf_copy(fd, buf, limit, desc...) \
-	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-	                         buf, BUFFER_WRITE_VBUF, NULL, \
+	buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+	                         buf, BUFFER_WRITE_VBUF, \
 	                         limit, desc)
 # define fd_null_copy(fd, limit, desc...) \
 	if (lseek(fd, limit, SEEK_CUR) == -1) { \
 		if (errno != ESPIPE) \
 			ohshite(desc); \
-		buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, NULL, \
-		                         NULL, BUFFER_WRITE_NULL, NULL, \
+		buffer_copy_setup_IntPtr(fd, BUFFER_READ_FD, \
+		                         NULL, BUFFER_WRITE_NULL, \
 		                         limit, desc); \
 	}
 # define stream_null_copy(file, limit, desc...) \
 	if (fseek(file, limit, SEEK_CUR) == -1) { \
 		if (errno != EBADF) \
 			ohshite(desc); \
-		buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, NULL, \
-		                         NULL, BUFFER_WRITE_NULL, NULL, \
+		buffer_copy_setup_PtrPtr(file, BUFFER_READ_STREAM, \
+		                         NULL, BUFFER_WRITE_NULL, \
 		                         limit, desc); \
 	}
 # define stream_fd_copy(file, fd, limit, desc...)\
-	buffer_copy_setup_PtrInt(file, BUFFER_READ_STREAM, NULL, \
-	                         fd, BUFFER_WRITE_FD, NULL, \
+	buffer_copy_setup_PtrInt(file, BUFFER_READ_STREAM, \
+	                         fd, BUFFER_WRITE_FD, \
 	                         limit, desc)
 #endif /* HAVE_C99 */
 
-off_t buffer_copy_setup_PtrInt(void *p, int typeIn, void *procIn,
-                               int i, int typeOut, void *procOut,
+off_t buffer_copy_setup_PtrInt(void *p, int typeIn,
+                               int i, int typeOut,
                                off_t limit, const char *desc,
-                               ...) DPKG_ATTR_PRINTF(8);
-off_t buffer_copy_setup_PtrPtr(void *p1, int typeIn, void *procIn,
-                               void *p2, int typeOut, void *procOut,
+                               ...) DPKG_ATTR_PRINTF(6);
+off_t buffer_copy_setup_PtrPtr(void *p1, int typeIn,
+                               void *p2, int typeOut,
                                off_t limit, const char *desc,
-                               ...) DPKG_ATTR_PRINTF(8);
-off_t buffer_copy_setup_IntPtr(int i, int typeIn, void *procIn,
-                               void *p, int typeOut, void *procOut,
+                               ...) DPKG_ATTR_PRINTF(6);
+off_t buffer_copy_setup_IntPtr(int i, int typeIn,
+                               void *p, int typeOut,
                                off_t limit, const char *desc,
-                               ...) DPKG_ATTR_PRINTF(8);
-off_t buffer_copy_setup_IntInt(int i1, int typeIn, void *procIn,
-                               int i2, int typeOut, void *procOut,
+                               ...) DPKG_ATTR_PRINTF(6);
+off_t buffer_copy_setup_IntInt(int i1, int typeIn,
+                               int i2, int typeOut,
                                off_t limit, const char *desc,
-                               ...) DPKG_ATTR_PRINTF(8);
-off_t buffer_copy_setup(buffer_arg argIn, int typeIn, void *procIn,
-                        buffer_arg argOut, int typeOut, void *procOut,
+                               ...) DPKG_ATTR_PRINTF(6);
+off_t buffer_copy_setup(buffer_arg argIn, int typeIn,
+                        buffer_arg argOut, int typeOut,
                         off_t limit, const char *desc);
 off_t buffer_write(buffer_data_t data, void *buf,
                    off_t length, const char *desc);