Kurt,
I applied these and zelously went through and made sure everything
in those files is type-safe. Now the result isn't releaseable on 32-bit
platforms, it compiles fine, but it's causing segmentation faults after a
few minutes of operation. :-/
I will keep investigating as I have time... I think my wife wants to
watch a movie I've seen a dozen times tonight so I may have a chance to hack
a bit more then. :-)
If you're interested, the results are here... I'm interested in
seeing if they at least compile in amd64 now:
http://www.crackerjack.net/mod_bt/debian/sid/
I'll let you know again when I have something I think will actually
work.
Cheers,
Tyler
Kurt Roeckx <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 11, 2006 at 11:23:23AM -0700, Tyler MacDonald wrote:
> > Thanks Kurt,
> > I've been working through your patch and correcting the code in
> > dev... If you're willing, I would like to send you my results when I'm done
> > to test again.
>
> Sure, just send me the diff or some url or something.
>
> > > Then I got:
> > > Tracker.xs: In function 'XS_Net__BitTorrent__LibBT__Tracker_Infohash':
> > > Tracker.xs:576: warning: passing argument 3 of 'Perl_sv_2pv_flags' from
> > > incompatible pointer type
> > > Tracker.xs: In function
> > > 'XS_Net__BitTorrent__LibBT__Tracker__Infohash_Peer':
> > > Tracker.xs:1047: warning: passing argument 3 of 'Perl_sv_2pv_flags' from
> > > incompatible pointer type
>
> So, I've fixed those an others too. I've attached the complete
> diff.
>
>
> Kurt
>
> --- src/libbtutil/util/bt_nice_size.c.old 2006-07-10 23:40:58.000000000
> +0200
> +++ src/libbtutil/util/bt_nice_size.c 2006-07-10 23:44:04.000000000 +0200
> @@ -7,6 +7,7 @@
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> +#include <inttypes.h>
>
> #define SZSTR 64
>
> @@ -31,7 +32,7 @@
> }
> else
> {
> - snprintf(szstr, SZSTR, "%llub", size);
> + snprintf(szstr, SZSTR, "%" PRIu64 "b", size);
> }
>
> rv = apr_pstrdup(p, szstr);
> --- src/libbtutil/types/bt_metainfo.c.old 2006-07-10 23:45:09.000000000
> +0200
> +++ src/libbtutil/types/bt_metainfo.c 2006-07-10 23:53:42.000000000 +0200
> @@ -40,7 +40,7 @@
>
> if(sinfo.st_size > BT_MAX_METAINFO_SIZE) {
> fprintf(
> - stderr, "%s: file to large (%llu bytes > %u bytes)",
> + stderr, "%s: file to large (%zu bytes > %u bytes)",
> path, sinfo.st_size, BT_MAX_METAINFO_SIZE
> );
> return NULL;
> @@ -60,7 +60,7 @@
>
> if((rv = apr_file_read(file, buf, &len)) != APR_SUCCESS) {
> fprintf(
> - stderr, "Failed to read %llu bytes from %s: %s\n",
> + stderr, "Failed to read %zu bytes from %s: %s\n",
> sinfo.st_size, path,
> apr_strerror(rv, errorstr, BT_SHORT_STRING)
> );
> @@ -70,7 +70,7 @@
> if(len != sinfo.st_size) {
> fprintf(
> stderr,
> - "%s: expected %llu bytes, but got %"SF"!\n", path,
> sinfo.st_size, len
> + "%s: expected %zu bytes, but got %"SF"!\n", path, sinfo.st_size,
> len
> );
> return NULL;
> }
> --- src/libbttracker/tracker/btt_tracker_alloc.c.old 2006-07-10
> 23:54:53.000000000 +0200
> +++ src/libbttracker/tracker/btt_tracker_alloc.c 2006-07-10
> 23:55:52.000000000 +0200
> @@ -122,13 +122,13 @@
> rv = NULL;
> } else {
> if((ret = apr_shm_create(&rv, size, shfile, p)) != APR_SUCCESS) {
> - fprintf(stderr, "apr_shm_create(&rv, %d, \"%s\", pool) failed: %s\n",
> size, shfile, apr_strerror(ret, btt_error_msg, sizeof(btt_error_msg)));
> + fprintf(stderr, "apr_shm_create(&rv, %zd, \"%s\", pool) failed:
> %s\n", size, shfile, apr_strerror(ret, btt_error_msg, sizeof(btt_error_msg)));
> fflush(stderr);
> rv = NULL;
> }
> }
> } else {
> - fprintf(stderr, "apr_shm_create(&rv, %d, \"%s\", pool) failed: %s\n",
> size, shfile, apr_strerror(ret, btt_error_msg, sizeof(btt_error_msg)));
> + fprintf(stderr, "apr_shm_create(&rv, %zd, \"%s\", pool) failed: %s\n",
> size, shfile, apr_strerror(ret, btt_error_msg, sizeof(btt_error_msg)));
> fflush(stderr);
> rv = NULL;
> }
> @@ -189,7 +189,7 @@
> return NULL;
> }
> } else {
> - fprintf(stderr, "bt_tracker_alloc(): Failed to allocate %d
> bytes!\n", sizeof(btt_tracker));
> + fprintf(stderr, "bt_tracker_alloc(): Failed to allocate %zd
> bytes!\n", sizeof(btt_tracker));
> fflush(stderr);
> return NULL;
> }
> --- src/libbttracker/types/btt_infohash.c.old 2006-07-10 23:56:48.000000000
> +0200
> +++ src/libbttracker/types/btt_infohash.c 2006-07-11 00:02:16.000000000
> +0200
> @@ -18,6 +18,7 @@
> /* libc */
> #include <time.h>
> #include <stdio.h>
> +#include <inttypes.h>
> /* other libs */
> #include <apr.h>
> #include <apr_pools.h>
> @@ -79,7 +80,7 @@
> "<TR><TH>Infohash:</TH><TD>%s</TH></TR>\n"
> "<TR><TH>Filename:</TH><TD>%s</TD></TR>\n"
> "<TR><TH>File Size:</TH><TD>%s</TD></TR>\n"
> - "<TR><TH>Announce Hits:</TH><TD>%llu</TD></TR>\n"
> + "<TR><TH>Announce Hits:</TH><TD>%" PRIu64 "</TD></TR>\n"
> "<TR><TH>Max Uploaded/Downloaded:</TH><TD>%s/%s</TD></TR>\n"
> "<TR><TH>Min/Max Left:</TH><TD>%s/%s</TD></TR>\n"
> "<TR><TH>Peers/Seeds/Shields:</TH><TD>%u/%u/%u</TD></TR>\n"
> @@ -121,7 +122,7 @@
> "Infohash: %s\n"
> "Filename: %s\n"
> "File Size: %s\n"
> - "Announce Hits: %llu\n"
> + "Announce Hits: %" PRIu64 "\n"
> "Max Uploaded: %s\n"
> "Mac Downloaded: %s\n"
> "Min/Max Left: %s/%s\n"
> @@ -171,7 +172,7 @@
> char* rv = apr_psprintf
> (
> p,
> -
> "20:....................d8:completei%ue10:downloadedi%ue10:incompletei%ue4:name%u:%s4:sizei%lluee",
> +
> "20:....................d8:completei%ue10:downloadedi%ue10:incompletei%ue4:name%zu:%s4:sizei%"
> PRIu64 "ee",
> complete, infohash->completes, infohash->peers - infohash->seeds,
> strlen(infohash->filename),
> infohash->filename, infohash->filesize
> );
> --- src/libbttracker/types/btt_peer.c.old 2006-07-11 00:03:22.000000000
> +0200
> +++ src/libbttracker/types/btt_peer.c 2006-07-11 00:04:54.000000000 +0200
> @@ -122,7 +122,7 @@
> fprintf(
> stderr,
> "bt_peer_req2struct(): got an invalid infohash "
> - "of length %i\n", fp.value_len
> + "of length %zi\n", fp.value_len
> );
> fflush(stderr);
> return 0;
> @@ -135,7 +135,7 @@
> fprintf(
> stderr,
> "bt_peer_req2struct(): got an invalid peerid "
> - "of length %i\n", fp.value_len
> + "of length %zi\n", fp.value_len
> );
> fflush(stderr);
> return 0;
> @@ -175,7 +175,7 @@
> fprintf(
> stderr,
> "bt_peer_req2struct(): Got an invalid event "
> - "of length %i\n", fp.value_len
> + "of length %zi\n", fp.value_len
> );
> fflush(stderr);
> return 0;
> @@ -256,7 +256,7 @@
> int len = 0;
>
> rv = apr_psprintf(
> - p, "d2:ip%u:%s4:porti%uee", strlen(ip), ip,
> + p, "d2:ip%zu:%s4:porti%uee", strlen(ip), ip,
> ntohs(peer->address.sin_port)
> );
> len = strlen(rv);
> @@ -268,11 +268,11 @@
> int btt_peer2bencode(apr_pool_t* p, btt_peer* peer, char **result) {
> char *rv = NULL;
> char *ip = apr_pstrdup(p, inet_ntoa(peer->address.sin_addr));
> - int iplen = strlen(apr_psprintf(p, "%u%s", strlen(ip), ip));
> + int iplen = strlen(apr_psprintf(p, "%zu%s", strlen(ip), ip));
> int len = 0;
>
> rv = apr_psprintf(
> - p, "d2:ip%u:%s7:peer id20:xxxxxxxxxxxxxxxxxxxx4:porti%uee",
> + p, "d2:ip%zu:%s7:peer id20:xxxxxxxxxxxxxxxxxxxx4:porti%uee",
> strlen(ip), ip, ntohs(peer->address.sin_port)
> );
>
> --- src/libbttracker/types/btt_tracker.c.old 2006-07-11 00:05:53.000000000
> +0200
> +++ src/libbttracker/types/btt_tracker.c 2006-07-11 00:08:38.000000000
> +0200
> @@ -15,6 +15,7 @@
> * limitations under the License.
> */
>
> +#include <inttypes.h>
> /* other libs */
> #include <apr.h>
> #include <apr_pools.h>
> @@ -136,8 +137,8 @@
> " <TR><TH>Startup Time:</TH><TD>%s</TD></TR>\n"
> " <TR><TH>Hashes:</TH><TD>%u</TD></TR>\n"
> " <TR><TH>Peers:</TH><TD>%u</TD></TR>\n"
> - " <TR><TH>Announces:</TH><TD>%llu (%.02f/s)</TD></TR>\n"
> - " <TR><TH>Faulty Announces:</TH><TD>%llu</TD></TR>\n"
> + " <TR><TH>Announces:</TH><TD>%" PRIu64 " (%.02f/s)</TD></TR>\n"
> + " <TR><TH>Faulty Announces:</TH><TD>%" PRIu64 "</TD></TR>\n"
> " <TR><TH>Peers Returned:</TH><TD>0 < %u < %u</TD></TR>\n"
> " <TR><TH>Return Interval:</TH><TD>%s</TD></TR>\n"
> " <TR><TH>Hash Expiry:</TH><TD>%lus - %lus (Watermark %u)</TD></TR>\n"
> @@ -206,8 +207,8 @@
> " <NumRequests>%u</NumRequests>\n"
> " <NumHashes>%u</NumHashes>\n"
> " <NumPeers>%u</NumPeers>\n"
> - " <Announces>%llu</Announces>\n"
> - " <BadAnnounces>%llu</BadAnnounces>\n"
> + " <Announces>%" PRIu64 "</Announces>\n"
> + " <BadAnnounces>%" PRIu64 "</BadAnnounces>\n"
> " <StartT>%lu</StartT>\n"
> " <MasterPID>%u</MasterPID>\n"
> " <ServerTime>%lu</ServerTime>\n"
> @@ -215,7 +216,7 @@
> " <DB>\n"
> " <Open>%u</Open>\n"
> " <Dir>%s</Dir>\n"
> - " <Cache>%u</Cache>\n"
> + " <Cache>%zu</Cache>\n"
> " </DB>\n"
> "</Tracker>\n",
> tracker->c->random_retry,
> --- src/libbttracker/Net-BitTorrent-LibBT-Tracker/Tracker.xs.old
> 2006-07-11 20:35:17.000000000 +0200
> +++ src/libbttracker/Net-BitTorrent-LibBT-Tracker/Tracker.xs 2006-07-11
> 20:37:55.000000000 +0200
> @@ -572,12 +572,12 @@
> DB_TXN* txn = NULL;
> DBT key;
> int ret = 0;
> - unsigned int len = 0;
> + size_t len = 0;
> char* infohash = SvPV(h, len);
>
> if(len != BT_INFOHASH_LEN)
> {
> - fprintf(stderr, "Net::BitTorrent::LibBT::Tracker->Infohash(): len %u
> != %u\n", len, BT_INFOHASH_LEN);
> + fprintf(stderr, "Net::BitTorrent::LibBT::Tracker->Infohash(): len %zu
> != %u\n", len, BT_INFOHASH_LEN);
> fflush(stderr);
> XSRETURN_UNDEF;
> }
> @@ -1043,12 +1043,12 @@
> DB_TXN* txn = NULL;
> DBT key;
> int ret = 0;
> - unsigned int len = 0;
> + size_t len = 0;
> char* peer_id = SvPV(inpeerid, len);
>
> if(len != BT_PEERID_LEN)
> {
> - fprintf(stderr, "Net::BitTorrent::LibBT::Tracker->Peer(): len %u !=
> %u\n", len, BT_PEERID_LEN);
> + fprintf(stderr, "Net::BitTorrent::LibBT::Tracker->Peer(): len %zu !=
> %u\n", len, BT_PEERID_LEN);
> fflush(stderr);
> XSRETURN_UNDEF;
> }
> --- src/apache2/php_mod_bt/php_mod_bt.c.old 2006-07-11 20:39:04.000000000
> +0200
> +++ src/apache2/php_mod_bt/php_mod_bt.c 2006-07-11 20:41:29.000000000
> +0200
> @@ -19,6 +19,7 @@
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <arpa/inet.h>
> +#include <inttypes.h>
> /* php */
> #include "php.h"
> #include "SAPI.h"
> @@ -144,15 +145,15 @@
> hash_str = bt_str_infohash(p, hash->infohash);
> add_assoc_stringl(rv, "infohash", hash_str, strlen(hash_str), 1);
> add_assoc_stringl(rv, "filename", hash->filename, strlen(hash->filename),
> 1);
> - size_str = apr_psprintf(p, "%llu", hash->filesize);
> + size_str = apr_psprintf(p, "%" PRIu64, hash->filesize);
> add_assoc_stringl(rv, "filesize", size_str, strlen(size_str), 1);
> - size_str = apr_psprintf(p, "%llu", hash->max_uploaded);
> + size_str = apr_psprintf(p, "%" PRIu64, hash->max_uploaded);
> add_assoc_stringl(rv, "max_uploaded", size_str, strlen(size_str), 1);
> - size_str = apr_psprintf(p, "%llu", hash->max_downloaded);
> + size_str = apr_psprintf(p, "%" PRIu64, hash->max_downloaded);
> add_assoc_stringl(rv, "max_downloaded", size_str, strlen(size_str), 1);
> - size_str = apr_psprintf(p, "%llu", hash->max_left);
> + size_str = apr_psprintf(p, "%" PRIu64, hash->max_left);
> add_assoc_stringl(rv, "max_left", size_str, strlen(size_str), 1);
> - size_str = apr_psprintf(p, "%llu", hash->min_left);
> + size_str = apr_psprintf(p, "%" PRIu64, hash->min_left);
> add_assoc_stringl(rv, "min_left", size_str, strlen(size_str), 1);
> add_assoc_long(rv, "hits", hash->hits);
> add_assoc_long(rv, "peers", hash->peers);
> @@ -413,11 +414,11 @@
> add_assoc_long(rv, "num_want", peer->num_want);
> add_assoc_long(rv, "num_got", peer->num_got);
> add_assoc_long(rv, "announce_bytes", peer->announce_bytes);
> - size_str = apr_psprintf(p, "%llu", peer->uploaded);
> + size_str = apr_psprintf(p, "%" PRIu64, peer->uploaded);
> add_assoc_stringl(rv, "uploaded", size_str, strlen(size_str), 1);
> - size_str = apr_psprintf(p, "%llu", peer->downloaded);
> + size_str = apr_psprintf(p, "%" PRIu64, peer->downloaded);
> add_assoc_stringl(rv, "downloaded", size_str, strlen(size_str), 1);
> - size_str = apr_psprintf(p, "%llu", peer->left);
> + size_str = apr_psprintf(p, "%" PRIu64, peer->left);
> add_assoc_stringl(rv, "left", size_str, strlen(size_str), 1);
>
> return rv;
> --- src/tests/types.c.old 2006-07-11 20:43:01.000000000 +0200
> +++ src/tests/types.c 2006-07-11 20:43:36.000000000 +0200
> @@ -9,12 +9,12 @@
> printf
> (
> "Sizes of libbtt Data Strcutres:\n"
> - " btt_db: % 4d\n"
> - " btt_tracker_stats: % 4d\n"
> - " btt_tracker_config: % 4d\n"
> - " btt_tracker: % 4d\n"
> - " btt_infohash: % 4d\n"
> - " btt_peer: % 4d\n",
> + " btt_db: % 4zd\n"
> + " btt_tracker_stats: % 4zd\n"
> + " btt_tracker_config: % 4zd\n"
> + " btt_tracker: % 4zd\n"
> + " btt_infohash: % 4zd\n"
> + " btt_peer: % 4zd\n",
> sizeof(btt_db), sizeof(btt_tracker_stats), sizeof(btt_tracker_config),
> sizeof(btt_tracker), sizeof(btt_infohash), sizeof(btt_peer)
> );
> exit(0);
--
Tank will paradigmatically harness 24/365 mindshares.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]