Skip to content

Instantly share code, notes, and snippets.

@kode54
Created May 17, 2024 00:38
Show Gist options
  • Save kode54/1044dc5cd31c614ed1e92b4155a0d0c5 to your computer and use it in GitHub Desktop.
Save kode54/1044dc5cd31c614ed1e92b4155a0d0c5 to your computer and use it in GitHub Desktop.
Patch to get zsync2 building with GCC14, likely no less functional than it was before, considering it doesn't try to use off64_t instead of off_t
diff --git a/lib/libzsync/zsync.c b/lib/libzsync/zsync.c
index b425db9..02c47ad 100644
--- a/lib/libzsync/zsync.c
+++ b/lib/libzsync/zsync.c
@@ -40,6 +40,8 @@
#include <unistd.h>
#include <string.h>
#include <ctype.h>
+
+#define __USE_XOPEN 1
#include <time.h>
#include <arpa/inet.h>
@@ -457,12 +459,12 @@ const char *const *zsync_get_urls(struct zsync_state *zs, int *n, int *t) {
if (zs->zmap && zs->nzurl) {
*n = zs->nzurl;
*t = 1;
- return zs->zurl;
+ return (const char *const *) zs->zurl;
}
else {
*n = zs->nurl;
*t = 0;
- return zs->url;
+ return (const char *const *) zs->url;
}
}
@@ -946,8 +948,10 @@ static int zsync_receive_data_compressed(struct zsync_receiver *zr,
zr->strm.avail_in = len;
if (zr->strm.total_in == 0 || offset != zr->strm.total_in) {
+ long long outoffset = zr->outoffset;
zsync_configure_zstream_for_zdata(zr->zs, &(zr->strm), offset,
- &(zr->outoffset));
+ &outoffset);
+ zr->outoffset = (off_t) outoffset;
/* On first iteration, we might be reading an incomplete block from zsync's point of view. Limit avail_out so we can stop after doing that and realign with the buffer. */
zr->strm.avail_out = blocksize - (zr->outoffset % blocksize);
diff --git a/src/format_string.h b/src/format_string.h
index 7b21773..d114969 100644
--- a/src/format_string.h
+++ b/src/format_string.h
@@ -22,16 +22,16 @@
#endif
#if SIZEOF_OFF_T == 8
-# ifdef PRIu64
-# define OFF_T_PF "%" PRIu64
+# ifdef PRIi64
+# define OFF_T_PF "%" PRIi64
# else
-# define OFF_T_PF "%llu"
+# define OFF_T_PF "%lld"
# endif
#else
-# ifdef PRIu32
-# define OFF_T_PF "%" PRIu32
+# ifdef PRIi32
+# define OFF_T_PF "%" PRIi32
# else
-# define OFF_T_PF "%lu"
+# define OFF_T_PF "%ld"
# endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment