소스 검색

dpkg-split: Do not pass partsize to mksplit() and compute it internally

Guillem Jover 15 년 전
부모
커밋
1d779cecab
1개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 5
      dpkg-split/split.c

+ 5 - 5
dpkg-split/split.c

@@ -110,14 +110,15 @@ clean_msdos_filename(char *filename)
 }
 
 static int
-mksplit(const char *file_src, const char *prefix, size_t partsize,
-        size_t maxpartsize, bool msdos)
+mksplit(const char *file_src, const char *prefix, size_t maxpartsize,
+        bool msdos)
 {
 	int fd_src;
 	struct stat st;
 	char hash[MD5HASHLEN + 1];
 	char *package, *version;
 	int nparts, curpart;
+	off_t partsize;
 	char *prefixdir = NULL, *msdos_prefix = NULL;
 	struct varbuf file_dst = VARBUF_INIT;
 	struct varbuf partmagic = VARBUF_INIT;
@@ -139,6 +140,7 @@ mksplit(const char *file_src, const char *prefix, size_t partsize,
 	package = deb_field(file_src, "Package");
 	version = deb_field(file_src, "Version");
 
+	partsize = maxpartsize - HEADERALLOWANCE;
 	nparts = (st.st_size + partsize - 1) / partsize;
 
 	setvbuf(stdout, NULL, _IONBF, 0);
@@ -242,7 +244,6 @@ void
 do_split(const char *const *argv)
 {
 	const char *sourcefile, *prefix;
-	size_t partsize;
 
 	sourcefile = *argv++;
 	if (!sourcefile)
@@ -263,9 +264,8 @@ do_split(const char *const *argv)
 		}
 		prefix = palloc;
 	}
-	partsize = opt_maxpartsize - HEADERALLOWANCE;
 
-	mksplit(sourcefile, prefix, partsize, opt_maxpartsize, opt_msdos);
+	mksplit(sourcefile, prefix, opt_maxpartsize, opt_msdos);
 
 	exit(0);
 }