[issue1028] cpdup: not 64-bit clean

Michel Salim sinknull at crater.dragonflybsd.org
Wed Jun 11 13:18:51 PDT 2008


Michel Salim <salimma at fedoraproject.org> added the comment:

Here is a patch implementing the explicit casts. I've used size_t rather than
int for the integral conversions of pointers.

_____________________________________________________
DragonFly issue tracker <bugs at lists.dragonflybsd.org>
<https://bugs.dragonflybsd.org/issue1028>
_____________________________________________________--- cpdup-1.11/hcproto.c.explicit_sizes	2008-05-22 19:34:41.000000000 -0400
+++ cpdup-1.11/hcproto.c	2008-06-11 14:40:46.000000000 -0400
@@ -336,7 +336,7 @@
     struct HCHead *head;
     struct HCLeaf *item;
     struct dirent *den;
-    int desc = 0;
+    size_t desc = 0;
 
     if (hc == NULL || hc->host == NULL)
 	return(opendir(path));
@@ -355,7 +355,7 @@
 	}
     }
     if (hcc_get_descriptor(hc, desc, HC_DESC_DIR)) {
-	fprintf(stderr, "hc_opendir: remote reused active descriptor %d\n",
+	fprintf(stderr, "hc_opendir: remote reused active descriptor %zd\n",
 		desc);
 	return(NULL);
     }
@@ -406,12 +406,12 @@
 	return(readdir(dir));
 
     trans = hcc_start_command(hc, HC_READDIR);
-    hcc_leaf_int32(trans, LC_DESCRIPTOR, (int)dir);
+    hcc_leaf_int32(trans, LC_DESCRIPTOR, (size_t)dir);
     if ((head = hcc_finish_command(trans)) == NULL)
 	return(NULL);
     if (head->error)
 	return(NULL);	/* XXX errno */
-    den = hcc_get_descriptor(hc, (int)dir, HC_DESC_DIR);
+    den = hcc_get_descriptor(hc, (size_t)dir, HC_DESC_DIR);
     if (den == NULL)
 	return(NULL);	/* XXX errno */
     if (den->d_name)
@@ -476,13 +476,13 @@
 
     if (hc == NULL || hc->host == NULL)
 	return(closedir(dir));
-    den = hcc_get_descriptor(hc, (int)dir, HC_DESC_DIR);
+    den = hcc_get_descriptor(hc, (size_t)dir, HC_DESC_DIR);
     if (den) {
 	free(den);
-	hcc_set_descriptor(hc, (int)dir, NULL, HC_DESC_DIR);
+	hcc_set_descriptor(hc, (size_t)dir, NULL, HC_DESC_DIR);
 
 	trans = hcc_start_command(hc, HC_CLOSEDIR);
-	hcc_leaf_int32(trans, LC_DESCRIPTOR, (int)dir);
+	hcc_leaf_int32(trans, LC_DESCRIPTOR, (size_t)dir);
 	if ((head = hcc_finish_command(trans)) == NULL)
 	    return(-1);
 	if (head->error)
--- cpdup-1.11/cpdup.c.explicit_sizes	2008-05-24 13:21:36.000000000 -0400
+++ cpdup-1.11/cpdup.c	2008-06-11 14:49:59.000000000 -0400
@@ -304,7 +304,7 @@
      * make any required connections.
      */
     if (src && (ptr = strchr(src, ':')) != NULL) {
-	asprintf(&SrcHost.host, "%*.*s", ptr - src, ptr - src, src);
+	asprintf(&SrcHost.host, "%*.*s", (int)(ptr - src), (int)(ptr - src), src);
 	src = ptr + 1;
 	if (UseCpFile) {
 	    fprintf(stderr, "The cpignore options are not currently supported for remote sources\n");
@@ -318,7 +318,7 @@
 	    exit(1);
     }
     if (dst && (ptr = strchr(dst, ':')) != NULL) {
-	asprintf(&DstHost.host, "%*.*s", ptr - dst, ptr - dst, dst);
+	asprintf(&DstHost.host, "%*.*s", (int)(ptr - dst), (int)(ptr - dst), dst);
 	dst = ptr + 1;
 	if (UseFSMIDOpt) {
 	    fprintf(stderr, "The FSMID options are not currently supported for remote targets\n");
--- cpdup-1.11/fsmid.c.explicit_sizes	2008-05-22 19:05:08.000000000 -0400
+++ cpdup-1.11/fsmid.c	2008-06-11 15:07:50.000000000 -0400
@@ -35,8 +35,8 @@
 
 	    for (node = FSMIDBase; node; node = node->fid_Next) {
 		if (node->fid_Accessed && node->fid_Code) {
-		    fprintf(fo, "%016llx %d %s\n", 
-			node->fid_Code, 
+		    fprintf(fo, "%016llx %zd %s\n", 
+			(long long unsigned)node->fid_Code, 
 			strlen(node->fid_Name),
 			node->fid_Name
 		    );




More information about the Bugs mailing list