mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 02:39:44 +00:00
Clean up string formatting for 64bit compilation
This commit is contained in:
parent
8ac359e550
commit
3855ff35c4
3
cli.h
3
cli.h
@ -92,7 +92,8 @@ int cli_optional_did(const char *text);
|
||||
|
||||
int cli_putchar(struct cli_context *context, char c);
|
||||
int cli_puts(struct cli_context *context, const char *str);
|
||||
int cli_printf(struct cli_context *context, const char *fmt, ...);
|
||||
int cli_printf(struct cli_context *context, const char *fmt, ...)
|
||||
__attribute__ (( format(printf,2,3) ));
|
||||
int cli_delim(struct cli_context *context, const char *opt);
|
||||
void cli_columns(struct cli_context *context, int columns, const char *names[]);
|
||||
void cli_row_count(struct cli_context *context, int rows);
|
||||
|
@ -390,7 +390,7 @@ void cli_put_long(struct cli_context *context, int64_t value, const char *delim)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
cli_printf(context, "%lld",value);
|
||||
cli_printf(context, "%" PRId64, value);
|
||||
cli_delim(context, delim);
|
||||
}
|
||||
|
||||
@ -950,7 +950,7 @@ int app_mdp_ping(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
time_ms_t rx_maxtime=-1;
|
||||
time_ms_t rx_ms=0;
|
||||
time_ms_t rx_times[1024];
|
||||
long long rx_count=0,tx_count=0;
|
||||
int rx_count=0,tx_count=0;
|
||||
|
||||
if (broadcast)
|
||||
WARN("broadcast ping packets will not be encrypted");
|
||||
@ -1004,7 +1004,7 @@ int app_mdp_ping(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
cli_printf(context, "%s: seq=%d time=%lldms hops=%d %s%s",
|
||||
alloca_tohex_sid(mdp.in.src.sid),
|
||||
(*rxseq)-firstSeq+1,
|
||||
delay,
|
||||
(long long)delay,
|
||||
hop_count,
|
||||
mdp.packetTypeAndFlags&MDP_NOCRYPT?"":" ENCRYPTED",
|
||||
mdp.packetTypeAndFlags&MDP_NOSIGN?"":" SIGNED");
|
||||
@ -1041,7 +1041,7 @@ int app_mdp_ping(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
|
||||
/* XXX Report final statistics before going */
|
||||
cli_printf(context, "--- %s ping statistics ---\n", alloca_tohex_sid_t(ping_sid));
|
||||
cli_printf(context, "%lld packets transmitted, %lld packets received, %3.1f%% packet loss\n",
|
||||
cli_printf(context, "%d packets transmitted, %d packets received, %3.1f%% packet loss\n",
|
||||
tx_count,rx_count,tx_count?(tx_count-rx_count)*100.0/tx_count:0);
|
||||
cli_printf(context, "round-trip min/avg/max/stddev%s = %lld/%.3f/%lld/%.3f ms\n",
|
||||
(samples<rx_count)?" (stddev calculated from last 1024 samples)":"",
|
||||
@ -1432,7 +1432,7 @@ int app_slip_test(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
bzero(&state,sizeof state);
|
||||
int outlen=slip_encode(SLIP_FORMAT_UPPER7,bufin,len,bufout,8192);
|
||||
for(i=0;i<outlen;i++) upper7_decode(&state,bufout[i]);
|
||||
unsigned long crc=Crc32_ComputeBuf( 0, state.dst, state.packet_length);
|
||||
uint32_t crc=Crc32_ComputeBuf( 0, state.dst, state.packet_length);
|
||||
if (crc!=state.crc) {
|
||||
WHYF("CRC error (%08x vs %08x)",crc,state.crc);
|
||||
dump("input",bufin,len);
|
||||
|
2
conf.c
2
conf.c
@ -84,7 +84,7 @@ static int reload(const char *path, int *resultp)
|
||||
if (meta.mtime == -1) {
|
||||
WARNF("config file %s does not exist -- using all defaults", path);
|
||||
} else if (meta.size > CONFIG_FILE_MAX_SIZE) {
|
||||
WHYF("config file %s is too big (%ld bytes exceeds limit %ld)", path, meta.size, CONFIG_FILE_MAX_SIZE);
|
||||
WHYF("config file %s is too big (%"PRId64" bytes exceeds limit %d)", path, meta.size, CONFIG_FILE_MAX_SIZE);
|
||||
return -1;
|
||||
} else if (meta.size <= 0) {
|
||||
WARNF("config file %s is zero size -- using all defaults", path);
|
||||
|
4
crypto.c
4
crypto.c
@ -62,13 +62,13 @@ int crypto_create_signature(unsigned char *key,
|
||||
|
||||
unsigned char sig[content_len + SIGNATURE_BYTES];
|
||||
/* Why does this primitive copy the whole input message? We don't want that message format, it just seems like a waste of effor to me. */
|
||||
unsigned long long length = 0;
|
||||
unsigned long long int length = 0;
|
||||
crypto_sign_edwards25519sha512batch(sig,&length,
|
||||
content,content_len,
|
||||
key);
|
||||
|
||||
if (length != sizeof(sig))
|
||||
RETURN(WHYF("Signing seems to have failed (%d, expected %d)",length,sizeof(sig)));
|
||||
RETURN(WHYF("Signing seems to have failed (%d, expected %d)",(int)length,(int)sizeof(sig)));
|
||||
|
||||
bcopy(sig, signature, SIGNATURE_BYTES);
|
||||
*sig_length=SIGNATURE_BYTES;
|
||||
|
@ -582,7 +582,7 @@ dna_helper_enqueue(overlay_mdp_frame *mdp, const char *did, const unsigned char
|
||||
return 0;
|
||||
}
|
||||
if (awaiting_reply) {
|
||||
WARNF("DNAHELPER currently awaiting reply -- dropping new request", request_buffer);
|
||||
WARN("DNAHELPER currently awaiting reply -- dropping new request");
|
||||
return 0;
|
||||
}
|
||||
char buffer[sizeof request_buffer];
|
||||
|
10
keyring.c
10
keyring.c
@ -145,7 +145,7 @@ keyring_file *keyring_open(const char *path)
|
||||
}
|
||||
r = fread(k->contexts[0]->KeyRingSalt, k->contexts[0]->KeyRingSaltLen, 1, k->file);
|
||||
if (r!=1) {
|
||||
WHYF_perror("fread(%p, %ld, 1, %s)", k->contexts[0]->KeyRingSalt, k->contexts[0]->KeyRingSaltLen, alloca_str_toprint(path));
|
||||
WHYF_perror("fread(%p, %d, 1, %s)", k->contexts[0]->KeyRingSalt, k->contexts[0]->KeyRingSaltLen, alloca_str_toprint(path));
|
||||
WHYF("Could not read salt from keyring file %s", path);
|
||||
keyring_free(k);
|
||||
return NULL;
|
||||
@ -614,7 +614,7 @@ static int keyring_pack_identity(keyring_context *c, keyring_identity *id, unsig
|
||||
// Ensure the correct number of bytes were written.
|
||||
unsigned packed = rotbuf_delta(&rbstart, &rbuf);
|
||||
if (packed != keypair_len) {
|
||||
WHYF("key type 0x%02x packed wrong length (packed %u, expecting %u)", ktype, packed, keypair_len);
|
||||
WHYF("key type 0x%02x packed wrong length (packed %u, expecting %u)", ktype, packed, (int)keypair_len);
|
||||
goto scram;
|
||||
}
|
||||
}
|
||||
@ -711,7 +711,7 @@ static keyring_identity *keyring_unpack_identity(unsigned char *slot, const char
|
||||
break;
|
||||
if (ktype < NELS(keytypes) && kt->unpacker) {
|
||||
if (config.debug.keyring)
|
||||
DEBUGF("unpack key type = 0x%02x at offset %u", ktype, rotbuf_position(&rbo));
|
||||
DEBUGF("unpack key type = 0x%02x at offset %u", ktype, (int)rotbuf_position(&rbo));
|
||||
struct rotbuf rbstart = rbuf;
|
||||
// Create keyring entries to hold the key pair.
|
||||
keypair *kp = NULL;
|
||||
@ -738,7 +738,7 @@ static keyring_identity *keyring_unpack_identity(unsigned char *slot, const char
|
||||
// If the number of bytes unpacked does not match the keypair length, it is probably an
|
||||
// empty slot.
|
||||
if (config.debug.keyring)
|
||||
DEBUGF("key type 0x%02x unpacked wrong length (unpacked %u, expecting %u)", ktype, unpacked, keypair_len);
|
||||
DEBUGF("key type 0x%02x unpacked wrong length (unpacked %u, expecting %u)", ktype, (int)unpacked, (int)keypair_len);
|
||||
keyring_free_identity(id);
|
||||
return NULL;
|
||||
}
|
||||
@ -761,7 +761,7 @@ static keyring_identity *keyring_unpack_identity(unsigned char *slot, const char
|
||||
}
|
||||
} else {
|
||||
if (config.debug.keyring)
|
||||
DEBUGF("unsupported key type 0x%02x at offset %u, skipping %u bytes", ktype, rotbuf_position(&rbo), keypair_len);
|
||||
DEBUGF("unsupported key type 0x%02x at offset %u, skipping %u bytes", ktype, (int)rotbuf_position(&rbo), (int)keypair_len);
|
||||
rotbuf_advance(&rbuf, keypair_len); // skip
|
||||
}
|
||||
}
|
||||
|
3
log.h
3
log.h
@ -100,7 +100,8 @@ void disable_log_stderr();
|
||||
void logFlush();
|
||||
void logArgv(int level, struct __sourceloc whence, const char *label, int argc, const char *const *argv);
|
||||
void logString(int level, struct __sourceloc whence, const char *str);
|
||||
void logMessage(int level, struct __sourceloc whence, const char *fmt, ...);
|
||||
void logMessage(int level, struct __sourceloc whence, const char *fmt, ...)
|
||||
__attribute__ (( format(printf,3,4) ));
|
||||
void vlogMessage(int level, struct __sourceloc whence, const char *fmt, va_list);
|
||||
void logConfigChanged();
|
||||
int logDump(int level, struct __sourceloc whence, char *name, const unsigned char *addr, size_t len);
|
||||
|
@ -119,7 +119,7 @@ int overlay_mdp_client_init()
|
||||
if(config.debug.io) DEBUGF("MDP client socket name='%s'",overlay_mdp_client_socket_path);
|
||||
}
|
||||
if (overlay_mdp_client_socket_path_len > sizeof(name.sun_path) - 1)
|
||||
FATALF("MDP socket path too long (%d > %d)", overlay_mdp_client_socket_path_len, sizeof(name.sun_path) - 1);
|
||||
FATALF("MDP socket path too long (%d > %d)", overlay_mdp_client_socket_path_len, (int)sizeof(name.sun_path) - 1);
|
||||
|
||||
bcopy(overlay_mdp_client_socket_path,name.sun_path,
|
||||
overlay_mdp_client_socket_path_len);
|
||||
|
@ -185,10 +185,10 @@ int monitor_client_read(int fd, struct monitor_state *res, struct monitor_comman
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
WHYF_perror("read(%d, %p, %ld)", fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset);
|
||||
WHYF_perror("read(%d, %p, %d)", fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset);
|
||||
return -1;
|
||||
} else if (bytesRead == 0) {
|
||||
WHYF("read(%d, %p, %ld) returned %d", fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset, bytesRead);
|
||||
WHYF("read(%d, %p, %d) returned %d", fd, res->buffer + oldOffset, MONITOR_CLIENT_BUFFER_SIZE - oldOffset, bytesRead);
|
||||
return -1;
|
||||
}
|
||||
res->bufferBytes+=bytesRead;
|
||||
|
@ -104,13 +104,13 @@ int monitor_setup_sockets()
|
||||
|
||||
int reuseP=1;
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuseP, sizeof reuseP) < 0) {
|
||||
WHYF_perror("setsockopt(%d, SOL_SOCKET, SO_REUSEADDR, &%d, %d)", sock, reuseP, sizeof reuseP);
|
||||
WHYF_perror("setsockopt(%d, SOL_SOCKET, SO_REUSEADDR, &%d, %d)", sock, reuseP, (int)sizeof reuseP);
|
||||
WHY("Could not indicate reuse addresses. Not necessarily a problem (yet)");
|
||||
}
|
||||
|
||||
int send_buffer_size=64*1024;
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &send_buffer_size, sizeof send_buffer_size)==-1)
|
||||
WHYF_perror("setsockopt(%d, SOL_SOCKET, SO_RCVBUF, &%d, %d)", sock, send_buffer_size, sizeof send_buffer_size);
|
||||
WHYF_perror("setsockopt(%d, SOL_SOCKET, SO_RCVBUF, &%d, %d)", sock, send_buffer_size, (int)sizeof send_buffer_size);
|
||||
|
||||
if (config.debug.io || config.debug.verbose_io)
|
||||
DEBUGF("Monitor server socket bound to %s", alloca_toprint(-1, &name, len));
|
||||
@ -318,7 +318,7 @@ static void monitor_new_client(int s) {
|
||||
goto error;
|
||||
}
|
||||
if (len < sizeof(ucred)) {
|
||||
WHYF("getsockopt(SO_PEERCRED) returned the wrong size (Got %d expected %d)", len, sizeof(ucred));
|
||||
WHYF("getsockopt(SO_PEERCRED) returned the wrong size (Got %d expected %d)", len, (int)sizeof(ucred));
|
||||
goto error;
|
||||
}
|
||||
otheruid = ucred.uid;
|
||||
|
2
net.c
2
net.c
@ -150,7 +150,7 @@ ssize_t recvwithttl(int sock,unsigned char *buffer, size_t bufferlen,int *ttl,
|
||||
return WHY_perror("recvmsg");
|
||||
|
||||
if (0 && config.debug.packetrx) {
|
||||
DEBUGF("recvmsg returned %lld (flags=%d, msg_controllen=%d)", (long long) len, msg.msg_flags, msg.msg_controllen);
|
||||
DEBUGF("recvmsg returned %d (flags=%d, msg_controllen=%d)", (int) len, msg.msg_flags, (int)msg.msg_controllen);
|
||||
dump("received data", buffer, len);
|
||||
}
|
||||
|
||||
|
@ -881,13 +881,13 @@ overlay_broadcast_ensemble(overlay_interface *interface,
|
||||
if (fsize == -1)
|
||||
return WHY_perror("lseek");
|
||||
if (config.debug.overlayinterfaces)
|
||||
DEBUGF("Write to interface %s at offset=%d", interface->name, fsize);
|
||||
DEBUGF("Write to interface %s at offset=%"PRId64, interface->name, fsize);
|
||||
}
|
||||
ssize_t nwrite = write(interface->alarm.poll.fd, &packet, sizeof(packet));
|
||||
if (nwrite == -1)
|
||||
return WHY_perror("write");
|
||||
if (nwrite != sizeof(packet))
|
||||
return WHYF("only wrote %lld of %lld bytes", nwrite, sizeof(packet));
|
||||
return WHYF("only wrote %d of %d bytes", (int)nwrite, (int)sizeof(packet));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ int rhizome_mdp_send_block(struct subscriber *dest, unsigned char *id, uint64_t
|
||||
char *id_str = alloca_tohex_bid(id);
|
||||
|
||||
if (config.debug.rhizome_tx)
|
||||
DEBUGF("Requested blocks for %s @%llx", id_str, fileOffset);
|
||||
DEBUGF("Requested blocks for %s @%"PRIx64, id_str, fileOffset);
|
||||
|
||||
/* Find manifest that corresponds to BID and version.
|
||||
If we don't have this combination, then do nothing.
|
||||
@ -174,7 +174,7 @@ int overlay_mdp_service_rhizomeresponse(overlay_mdp_frame *mdp)
|
||||
int count=mdp->out.payload_length-(1+16+8+8);
|
||||
unsigned char *bytes=&mdp->out.payload[1+16+8+8];
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Received %d bytes @ 0x%llx for %s* version 0x%llx",
|
||||
DEBUGF("Received %d bytes @ 0x%"PRIx64" for %s* version 0x%"PRIx64,
|
||||
count,offset,alloca_tohex(bidprefix,16),version);
|
||||
|
||||
/* Now see if there is a slot that matches. If so, then
|
||||
|
@ -522,7 +522,7 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
}else if(((mdp_sequence - frame->mdp_sequence)&0xFFFF) >= 64){
|
||||
// too late, we've sent too many packets for the next hop to correctly de-duplicate
|
||||
if (config.debug.overlayframes)
|
||||
DEBUGF("Retransmition of frame %p mdp seq %d, is too late to be de-duplicated", frame, frame->mdp_sequence, frame->interface_sent_sequence[packet->i], packet->seq);
|
||||
DEBUGF("Retransmition of frame %p mdp seq %d, is too late to be de-duplicated", frame, frame->mdp_sequence);
|
||||
frame = overlay_queue_remove(queue, frame);
|
||||
continue;
|
||||
}else{
|
||||
|
@ -314,7 +314,8 @@ int rhizome_add_manifest(rhizome_manifest *m_in,int ttl)
|
||||
if (config.debug.rhizome) DEBUG("No existing manifest");
|
||||
break;
|
||||
case 1:
|
||||
if (config.debug.rhizome) DEBUGF("Found existing version=%lld, new version=%lld", storedversion, m_in->version);
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Found existing version=%"PRId64", new version=%"PRId64, storedversion, m_in->version);
|
||||
if (m_in->version < storedversion)
|
||||
return WHY("Newer version exists");
|
||||
if (m_in->version == storedversion)
|
||||
|
@ -243,7 +243,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu
|
||||
} else if (strcasecmp(var, "name") == 0) {
|
||||
if (value[0] == '\0') {
|
||||
if (config.debug.rejecteddata)
|
||||
WARNF("Empty name", value);
|
||||
WARN("Empty name");
|
||||
m->errors++;
|
||||
}
|
||||
// TODO: complain if service is not MeshMS
|
||||
@ -458,7 +458,7 @@ int rhizome_manifest_set_ll(rhizome_manifest *m, char *var, int64_t value)
|
||||
{
|
||||
char svalue[100];
|
||||
|
||||
snprintf(svalue,100,"%lld",value);
|
||||
snprintf(svalue,100, "%" PRId64, value);
|
||||
|
||||
return rhizome_manifest_set(m,var,svalue);
|
||||
}
|
||||
|
@ -988,7 +988,7 @@ int rhizome_store_bundle(rhizome_manifest *m)
|
||||
if (sqlite_exec_void_retry(&retry, "COMMIT;") != -1){
|
||||
// This message used in tests; do not modify or remove.
|
||||
const char *service = rhizome_manifest_get(m, "service", NULL, 0);
|
||||
INFOF("RHIZOME ADD MANIFEST service=%s bid=%s version=%lld",
|
||||
INFOF("RHIZOME ADD MANIFEST service=%s bid=%s version=%"PRId64,
|
||||
service ? service : "NULL",
|
||||
alloca_tohex_sid(m->cryptoSignPublic),
|
||||
m->version
|
||||
@ -1027,7 +1027,7 @@ int rhizome_list_manifests(struct cli_context *context, const char *service, con
|
||||
strbuf_sprintf(b, " OFFSET %u", offset);
|
||||
|
||||
if (strbuf_overrun(b))
|
||||
RETURN(WHYF("SQL command too long: ", strbuf_str(b)));
|
||||
RETURN(WHYF("SQL command too long: %s", strbuf_str(b)));
|
||||
|
||||
sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT;
|
||||
sqlite3_stmt *statement = sqlite_prepare(&retry, "%s", strbuf_str(b));
|
||||
@ -1253,7 +1253,7 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found,
|
||||
DEBUGF("filehash=\"%s\"", filehash);
|
||||
sqlite3_bind_text(statement, field++, filehash, -1, SQLITE_STATIC);
|
||||
}
|
||||
size_t rows = 0;
|
||||
int rows = 0;
|
||||
while (sqlite_step_retry(&retry, statement) == SQLITE_ROW) {
|
||||
++rows;
|
||||
if (config.debug.rhizome) DEBUGF("Row %d", rows);
|
||||
@ -1279,7 +1279,7 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found,
|
||||
}
|
||||
const char *manifestblob = (char *) sqlite3_column_blob(statement, 1);
|
||||
size_t manifestblobsize = sqlite3_column_bytes(statement, 1); // must call after sqlite3_column_blob()
|
||||
long long q_version = sqlite3_column_int64(statement, 2);
|
||||
int64_t q_version = sqlite3_column_int64(statement, 2);
|
||||
const char *q_author = (const char *) sqlite3_column_text(statement, 3);
|
||||
|
||||
rhizome_manifest *blob_m = rhizome_new_manifest();
|
||||
@ -1294,11 +1294,11 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found,
|
||||
} else {
|
||||
const char *blob_service = rhizome_manifest_get(blob_m, "service", NULL, 0);
|
||||
const char *blob_id = rhizome_manifest_get(blob_m, "id", NULL, 0);
|
||||
long long blob_version = rhizome_manifest_get_ll(blob_m, "version");
|
||||
int64_t blob_version = rhizome_manifest_get_ll(blob_m, "version");
|
||||
const char *blob_filehash = rhizome_manifest_get(blob_m, "filehash", NULL, 0);
|
||||
long long blob_filesize = rhizome_manifest_get_ll(blob_m, "filesize");
|
||||
int64_t blob_filesize = rhizome_manifest_get_ll(blob_m, "filesize");
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Consider manifest.service=%s manifest.id=%s manifest.version=%lld", blob_service, q_manifestid, blob_version);
|
||||
DEBUGF("Consider manifest.service=%s manifest.id=%s manifest.version=%"PRId64, blob_service, q_manifestid, blob_version);
|
||||
if (q_author) {
|
||||
if (config.debug.rhizome)
|
||||
strbuf_sprintf(b, " .author=%s", q_author);
|
||||
@ -1312,12 +1312,12 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found,
|
||||
++inconsistent;
|
||||
}
|
||||
if (blob_version != q_version) {
|
||||
WARNF("MANIFESTS row id=%s has inconsistent blob: manifests.version=%lld, blob.version=%lld -- skipped",
|
||||
WARNF("MANIFESTS row id=%s has inconsistent blob: manifests.version=%"PRId64", blob.version=%"PRId64" -- skipped",
|
||||
q_manifestid, q_version, blob_version);
|
||||
++inconsistent;
|
||||
}
|
||||
if (blob_filesize != -1 && blob_filesize != m->fileLength) {
|
||||
WARNF("MANIFESTS row id=%s has inconsistent blob: known file size %lld, blob.filesize=%lld -- skipped",
|
||||
WARNF("MANIFESTS row id=%s has inconsistent blob: known file size %"PRId64", blob.filesize=%"PRId64" -- skipped",
|
||||
q_manifestid, m->fileLength, blob_filesize);
|
||||
++inconsistent;
|
||||
}
|
||||
@ -1335,7 +1335,7 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found,
|
||||
}
|
||||
}
|
||||
if (blob_service == NULL) {
|
||||
WARNF("MANIFESTS row id=%s has blob with no 'service' -- skipped", q_manifestid, blob_id);
|
||||
WARNF("MANIFESTS row id=%s has blob with no 'service' -- skipped", q_manifestid);
|
||||
++inconsistent;
|
||||
}
|
||||
if (!inconsistent) {
|
||||
@ -1367,8 +1367,8 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found,
|
||||
if (!inconsistent) {
|
||||
*found = blob_m;
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Found duplicate payload: service=%s%s version=%llu hexhash=%s",
|
||||
blob_service, strbuf_str(b), blob_m->version, blob_m->fileHexHash, q_author ? q_author : ""
|
||||
DEBUGF("Found duplicate payload: service=%s%s version=%"PRIu64" hexhash=%s",
|
||||
blob_service, strbuf_str(b), blob_m->version, blob_m->fileHexHash
|
||||
);
|
||||
ret = 1;
|
||||
break;
|
||||
@ -1401,8 +1401,8 @@ int rhizome_retrieve_manifest(const char *manifestid, rhizome_manifest *m)
|
||||
sqlite3_bind_text(statement, 1, manifestid, -1, SQLITE_STATIC);
|
||||
if (sqlite_step_retry(&retry, statement) == SQLITE_ROW){
|
||||
const char *manifestblob = (char *) sqlite3_column_blob(statement, 0);
|
||||
long long q_version = (long long) sqlite3_column_int64(statement, 1);
|
||||
long long q_inserttime = (long long) sqlite3_column_int64(statement, 2);
|
||||
int64_t q_version = sqlite3_column_int64(statement, 1);
|
||||
int64_t q_inserttime = sqlite3_column_int64(statement, 2);
|
||||
const char *q_author = (const char *) sqlite3_column_text(statement, 3);
|
||||
size_t manifestblobsize = sqlite3_column_bytes(statement, 0); // must call after sqlite3_column_blob()
|
||||
|
||||
@ -1417,7 +1417,7 @@ int rhizome_retrieve_manifest(const char *manifestid, rhizome_manifest *m)
|
||||
}
|
||||
|
||||
if (m->version!=q_version)
|
||||
WARNF("Version mismatch, manifest is %lld, database is %lld", m->version, q_version);
|
||||
WARNF("Version mismatch, manifest is %"PRId64", database is %"PRId64, m->version, q_version);
|
||||
|
||||
m->inserttime = q_inserttime;
|
||||
}else{
|
||||
@ -1557,8 +1557,8 @@ int rhizome_is_bar_interesting(unsigned char *bar){
|
||||
if (sqlite_step_retry(&retry, statement) == SQLITE_ROW){
|
||||
if (0){
|
||||
const char *q_id = (const char *) sqlite3_column_text(statement, 0);
|
||||
long long q_version = (long long) sqlite3_column_int64(statement, 1);
|
||||
DEBUGF("Already have %s, %lld (vs %s, %lld)", q_id, q_version, id_hex, version);
|
||||
int64_t q_version = sqlite3_column_int64(statement, 1);
|
||||
DEBUGF("Already have %s, %"PRId64" (vs %s, %"PRId64")", q_id, q_version, id_hex, version);
|
||||
}
|
||||
ret=0;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
rhizome_direct_bundle_iterator_free(&c);
|
||||
return NULL;
|
||||
}
|
||||
DEBUGF("unpickled size_high=%lld, limit_size_high=%lld",
|
||||
DEBUGF("unpickled size_high=%"PRId64", limit_size_high=%"PRId64,
|
||||
c->size_high,c->limit_size_high);
|
||||
DEBUGF("c->buffer_size=%d",c->buffer_size);
|
||||
|
||||
@ -338,7 +338,7 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
RHIZOME_BAR_PREFIX_BYTES);
|
||||
c->buffer_used+=1+RHIZOME_BAR_PREFIX_BYTES;
|
||||
who=-1;
|
||||
DEBUGF("They have previously unseen bundle %016llx*",
|
||||
DEBUGF("They have previously unseen bundle %016"PRIx64"*",
|
||||
rhizome_bar_bidprefix_ll(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
} else if (relation>0) {
|
||||
/* We have a bundle that they don't have any version of
|
||||
@ -350,7 +350,7 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
RHIZOME_BAR_PREFIX_BYTES);
|
||||
c->buffer_used+=1+RHIZOME_BAR_PREFIX_BYTES;
|
||||
who=+1;
|
||||
DEBUGF("We have previously unseen bundle %016llx*",
|
||||
DEBUGF("We have previously unseen bundle %016"PRIx64"*",
|
||||
rhizome_bar_bidprefix_ll(&usbuffer[10+us*RHIZOME_BAR_BYTES]));
|
||||
} else {
|
||||
/* We each have a version of this bundle, so see whose is newer */
|
||||
@ -365,7 +365,7 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
&c->buffer[c->buffer_offset_bytes+c->buffer_used+1],
|
||||
RHIZOME_BAR_PREFIX_BYTES);
|
||||
c->buffer_used+=1+RHIZOME_BAR_PREFIX_BYTES;
|
||||
DEBUGF("They have newer version of bundle %016llx* (%lld versus %lld)",
|
||||
DEBUGF("They have newer version of bundle %016"PRIx64"* (%"PRId64" versus %"PRId64")",
|
||||
rhizome_bar_bidprefix_ll(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
@ -376,12 +376,12 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
&c->buffer[c->buffer_offset_bytes+c->buffer_used+1],
|
||||
RHIZOME_BAR_PREFIX_BYTES);
|
||||
c->buffer_used+=1+RHIZOME_BAR_PREFIX_BYTES;
|
||||
DEBUGF("We have newer version of bundle %016llx* (%lld versus %lld)",
|
||||
DEBUGF("We have newer version of bundle %016"PRIx64"* (%"PRId64" versus %"PRId64")",
|
||||
rhizome_bar_bidprefix_ll(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
} else {
|
||||
DEBUGF("We both have the same version of %016llx*",
|
||||
DEBUGF("We both have the same version of %016"PRIx64"*",
|
||||
rhizome_bar_bidprefix_ll(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
}
|
||||
}
|
||||
@ -601,7 +601,7 @@ int rhizome_direct_bundle_iterator_pickle_range(rhizome_direct_bundle_cursor *r,
|
||||
pickled[0]=ltwov;
|
||||
for(v=0;v<4;v++) pickled[1+v]=r->start_bid_low[v];
|
||||
v=r->size_high;
|
||||
DEBUGF("pickling size_high=%lld",r->size_high);
|
||||
DEBUGF("pickling size_high=%"PRId64,r->size_high);
|
||||
ltwov=0;
|
||||
while(v>1) { ltwov++; v=v>>1; }
|
||||
pickled[1+4]=ltwov;
|
||||
@ -661,7 +661,7 @@ int rhizome_direct_bundle_iterator_fill(rhizome_direct_bundle_cursor *c,int max_
|
||||
if (max_bars==-1)
|
||||
max_bars=(c->buffer_size-c->buffer_offset_bytes)/RHIZOME_BAR_BYTES;
|
||||
|
||||
DEBUGF("Iterating cursor size high %lld..%lld, max_bars=%d",
|
||||
DEBUGF("Iterating cursor size high %"PRId64"..%"PRId64", max_bars=%d",
|
||||
c->size_high,c->limit_size_high,max_bars);
|
||||
|
||||
while (bundles_stuffed<max_bars&&c->size_high<=c->limit_size_high)
|
||||
@ -694,7 +694,7 @@ int rhizome_direct_bundle_iterator_fill(rhizome_direct_bundle_cursor *c,int max_
|
||||
c->size_low=c->size_high+1;
|
||||
c->size_high*=2;
|
||||
if (c->size_high<=1024) c->size_low=0;
|
||||
DEBUGF("size=%lld..%lld",c->size_low,c->size_high);
|
||||
DEBUGF("size=%"PRId64"..%"PRId64,c->size_low,c->size_high);
|
||||
/* Record that we covered to the end of that size bin */
|
||||
memset(c->bid_high,0xff,RHIZOME_MANIFEST_ID_BYTES);
|
||||
if (c->size_high>c->limit_size_high)
|
||||
@ -756,7 +756,7 @@ int rhizome_direct_get_bars(const unsigned char bid_low[RHIZOME_MANIFEST_ID_BYTE
|
||||
snprintf(query,1024,
|
||||
"SELECT BAR,ROWID,ID,FILESIZE FROM MANIFESTS"
|
||||
" WHERE"
|
||||
" FILESIZE BETWEEN %lld AND %lld"
|
||||
" FILESIZE BETWEEN %" PRId64 " AND %" PRId64
|
||||
" AND ID>='%s' AND ID<='%s'"
|
||||
// The following formulation doesn't remove the weird returning of
|
||||
// bundles with out of range filesize values
|
||||
@ -784,7 +784,7 @@ int rhizome_direct_get_bars(const unsigned char bid_low[RHIZOME_MANIFEST_ID_BYTE
|
||||
int ret;
|
||||
int64_t filesize = sqlite3_column_int64(statement, 3);
|
||||
if (filesize<size_low||filesize>size_high) {
|
||||
DEBUGF("WEIRDNESS ALERT: filesize=%lld, but query was: %s",
|
||||
DEBUGF("WEIRDNESS ALERT: filesize=%"PRId64", but query was: %s",
|
||||
filesize,query);
|
||||
break;
|
||||
}
|
||||
|
@ -685,7 +685,7 @@ static int receive_http_response(int sock, char *buffer, size_t buffer_len, stru
|
||||
int count;
|
||||
do {
|
||||
if ((count = read(sock, &buffer[len], buffer_len - len)) == -1)
|
||||
return WHYF_perror("read(%d, %p, %d)", sock, &buffer[len], buffer_len - len);
|
||||
return WHYF_perror("read(%d, %p, %d)", sock, &buffer[len], (int)buffer_len - len);
|
||||
len += count;
|
||||
} while (len < buffer_len && count != 0 && !http_header_complete(buffer, len, len));
|
||||
if (config.debug.rhizome_rx)
|
||||
@ -693,7 +693,7 @@ static int receive_http_response(int sock, char *buffer, size_t buffer_len, stru
|
||||
if (unpack_http_response(buffer, parts) == -1)
|
||||
return -1;
|
||||
if (parts->code != 200 && parts->code != 201) {
|
||||
INFOF("Failed HTTP request: server returned %003u %s", parts->code, parts->reason);
|
||||
INFOF("Failed HTTP request: server returned %03u %s", parts->code, parts->reason);
|
||||
return -1;
|
||||
}
|
||||
if (parts->content_length == -1) {
|
||||
@ -701,7 +701,7 @@ static int receive_http_response(int sock, char *buffer, size_t buffer_len, stru
|
||||
DEBUGF("Invalid HTTP reply: missing Content-Length header");
|
||||
return -1;
|
||||
}
|
||||
DEBUGF("content_length=%d", parts->content_length);
|
||||
DEBUGF("content_length=%"PRId64, parts->content_length);
|
||||
return len - (parts->content_start - buffer);
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ static int fill_buffer(int sock, unsigned char *buffer, int len, int buffer_size
|
||||
|
||||
void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
|
||||
{
|
||||
DEBUGF("Dispatch size_high=%lld",r->cursor->size_high);
|
||||
DEBUGF("Dispatch size_high=%"PRId64,r->cursor->size_high);
|
||||
rhizome_direct_transport_state_http *state = r->transport_specific_state;
|
||||
|
||||
unsigned char zerosid[SID_SIZE]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
|
@ -116,7 +116,7 @@ struct rhizome_fetch_candidate queue4[2];
|
||||
struct rhizome_fetch_candidate queue5[2];
|
||||
|
||||
#define NELS(a) (sizeof (a) / sizeof *(a))
|
||||
#define slotno(slot) ((struct rhizome_fetch_queue *)(slot) - &rhizome_fetch_queues[0])
|
||||
#define slotno(slot) (int)((struct rhizome_fetch_queue *)(slot) - &rhizome_fetch_queues[0])
|
||||
|
||||
/* Static allocation of the queue structures. Must be in order of ascending log_size_threshold.
|
||||
*/
|
||||
@ -240,7 +240,7 @@ static struct rhizome_fetch_candidate *rhizome_fetch_insert(struct rhizome_fetch
|
||||
struct rhizome_fetch_candidate * const c = &q->candidate_queue[i];
|
||||
struct rhizome_fetch_candidate * e = &q->candidate_queue[q->candidate_queue_size - 1];
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("insert queue[%d] candidate[%d]", q - rhizome_fetch_queues, i);
|
||||
DEBUGF("insert queue[%d] candidate[%d]", (int)(q - rhizome_fetch_queues), i);
|
||||
assert(i >= 0 && i < q->candidate_queue_size);
|
||||
assert(i == 0 || c[-1].manifest);
|
||||
if (e->manifest) // queue is full
|
||||
@ -266,7 +266,7 @@ static void rhizome_fetch_unqueue(struct rhizome_fetch_queue *q, int i)
|
||||
assert(i >= 0 && i < q->candidate_queue_size);
|
||||
struct rhizome_fetch_candidate *c = &q->candidate_queue[i];
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("unqueue queue[%d] candidate[%d] manifest=%p", q - rhizome_fetch_queues, i, c->manifest);
|
||||
DEBUGF("unqueue queue[%d] candidate[%d] manifest=%p", (int)(q - rhizome_fetch_queues), i, c->manifest);
|
||||
if (c->manifest) {
|
||||
rhizome_manifest_free(c->manifest);
|
||||
c->manifest = NULL;
|
||||
@ -368,7 +368,7 @@ int rhizome_manifest_version_cache_lookup(rhizome_manifest *m)
|
||||
if (sqlite_exec_int64(&dbVersion, "SELECT version FROM MANIFESTS WHERE id='%s';", id) == -1)
|
||||
return WHY("Select failure");
|
||||
if (dbVersion >= m->version) {
|
||||
if (0) WHYF("We already have %s (%lld vs %lld)", id, dbVersion, m->version);
|
||||
if (0) WHYF("We already have %s (%"PRId64" vs %"PRId64")", id, dbVersion, m->version);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -395,24 +395,24 @@ int rhizome_manifest_version_cache_lookup(rhizome_manifest *m)
|
||||
if (i==24) {
|
||||
/* Entries match -- so check version */
|
||||
int64_t rev = rhizome_manifest_get_ll(m,"version");
|
||||
if (1) DEBUGF("cached version %lld vs manifest version %lld", entry->version,rev);
|
||||
if (1) DEBUGF("cached version %"PRId64" vs manifest version %"PRId64, entry->version,rev);
|
||||
if (rev > entry->version) {
|
||||
/* If we only have an old version, try refreshing the cache
|
||||
by querying the database */
|
||||
if (sqlite_exec_int64(&entry->version, "select version from manifests where id='%s'", id) != 1)
|
||||
return WHY("failed to select stored manifest version");
|
||||
DEBUGF("Refreshed stored version from database: entry->version=%lld", entry->version);
|
||||
DEBUGF("Refreshed stored version from database: entry->version=%"PRId64, entry->version);
|
||||
}
|
||||
if (rev < entry->version) {
|
||||
/* the presented manifest is older than we have.
|
||||
This allows the caller to know that they can tell whoever gave them the
|
||||
manifest it's time to get with the times. May or not ever be
|
||||
implemented, but it would be nice. XXX */
|
||||
WHYF("cached version is NEWER than presented version (%lld is newer than %lld)",
|
||||
WHYF("cached version is NEWER than presented version (%"PRId64" is newer than %"PRId64")",
|
||||
entry->version,rev);
|
||||
return -2;
|
||||
} else if (rev<=entry->version) {
|
||||
/* the presented manifest is already stored. */
|
||||
/* the presented manifest is already stored. */
|
||||
if (1) DEBUG("cached version is NEWER/SAME as presented version");
|
||||
return -1;
|
||||
} else {
|
||||
@ -458,7 +458,7 @@ int rhizome_manifest_version_cache_lookup(rhizome_manifest *m)
|
||||
int64_t stored_version;
|
||||
if (sqlite_exec_int64(&stored_version, "select version from manifests where id='%s'", id) < 1)
|
||||
return WHY("database error reading stored manifest version"); // database is broken, we can't confirm that it is here
|
||||
DEBUGF("stored version=%lld, manifest_version=%lld (not fetching; remembering in cache)",
|
||||
DEBUGF("stored version=%"PRId64", manifest_version=%"PRId64" (not fetching; remembering in cache)",
|
||||
stored_version,manifest_version);
|
||||
slot=random()%RHIZOME_VERSION_CACHE_ASSOCIATIVITY;
|
||||
struct rhizome_manifest_version_cache_slot *entry = &rhizome_manifest_version_cache[bin][slot];
|
||||
@ -701,7 +701,7 @@ rhizome_fetch(struct rhizome_fetch_slot *slot, rhizome_manifest *m, const struct
|
||||
*/
|
||||
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Fetching bundle slot=%d bid=%s version=%lld size=%lld peerip=%s",
|
||||
DEBUGF("Fetching bundle slot=%d bid=%s version=%"PRId64" size=%"PRId64" peerip=%s",
|
||||
slotno(slot),
|
||||
bid,
|
||||
m->version,
|
||||
@ -794,8 +794,8 @@ rhizome_fetch(struct rhizome_fetch_slot *slot, rhizome_manifest *m, const struct
|
||||
if (schedule_fetch(slot) == -1)
|
||||
RETURN(-1);
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF(" started fetch bid %s version 0x%llx into %s, slot=%d filehash=%s",
|
||||
alloca_tohex_bid(slot->bid), (long long) slot->bidVersion,
|
||||
DEBUGF(" started fetch bid %s version 0x%"PRIx64" into %s, slot=%d filehash=%s",
|
||||
alloca_tohex_bid(slot->bid), slot->bidVersion,
|
||||
alloca_str_toprint(slot->manifest->dataFileName), slotno(slot), m->fileHexHash);
|
||||
RETURN(STARTED);
|
||||
}
|
||||
@ -966,7 +966,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct sock
|
||||
int priority=100; /* normal priority */
|
||||
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Considering import bid=%s version=%lld size=%lld priority=%d:", bid, m->version, m->fileLength, priority);
|
||||
DEBUGF("Considering import bid=%s version=%"PRId64" size=%"PRId64" priority=%d:", bid, m->version, m->fileLength, priority);
|
||||
|
||||
if (rhizome_manifest_version_cache_lookup(m)) {
|
||||
if (config.debug.rhizome_rx)
|
||||
@ -978,7 +978,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct sock
|
||||
if (config.debug.rhizome_rx) {
|
||||
int64_t stored_version;
|
||||
if (sqlite_exec_int64(&stored_version, "select version from manifests where id='%s'", bid) > 0)
|
||||
DEBUGF(" is new (have version %lld)", stored_version);
|
||||
DEBUGF(" is new (have version %"PRId64")", stored_version);
|
||||
}
|
||||
|
||||
if (m->fileLength == 0) {
|
||||
@ -998,7 +998,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct sock
|
||||
// Find the proper queue for the payload. If there is none suitable, it is an error.
|
||||
struct rhizome_fetch_queue *qi = rhizome_find_queue(m->fileLength);
|
||||
if (!qi) {
|
||||
WHYF("No suitable fetch queue for bundle size=%lld", m->fileLength);
|
||||
WHYF("No suitable fetch queue for bundle size=%"PRId64, m->fileLength);
|
||||
rhizome_manifest_free(m);
|
||||
RETURN(-1);
|
||||
}
|
||||
@ -1138,7 +1138,7 @@ static void rhizome_fetch_mdp_slot_callback(struct sched_ent *alarm)
|
||||
|
||||
long long now=gettime_ms();
|
||||
if (now-slot->last_write_time>slot->mdpIdleTimeout) {
|
||||
DEBUGF("MDP connection timed out: last RX %lldms ago (read %d of %d bytes)",
|
||||
DEBUGF("MDP connection timed out: last RX %lldms ago (read %"PRId64" of %"PRId64" bytes)",
|
||||
now-slot->last_write_time,
|
||||
slot->write_state.file_offset + slot->write_state.data_size,slot->write_state.file_length);
|
||||
rhizome_fetch_close(slot);
|
||||
@ -1146,7 +1146,7 @@ static void rhizome_fetch_mdp_slot_callback(struct sched_ent *alarm)
|
||||
return;
|
||||
}
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Timeout: Resending request for slot=0x%p (%d of %d received)",
|
||||
DEBUGF("Timeout: Resending request for slot=0x%p (%"PRId64" of %"PRId64" received)",
|
||||
slot,slot->write_state.file_offset + slot->write_state.data_size,slot->write_state.file_length);
|
||||
if (slot->bidP)
|
||||
rhizome_fetch_mdp_requestblocks(slot);
|
||||
@ -1202,7 +1202,7 @@ static int rhizome_fetch_mdp_requestblocks(struct rhizome_fetch_slot *slot)
|
||||
write_uint16(&mdp.out.payload[RHIZOME_MANIFEST_ID_BYTES+8+8+4],slot->mdpRXBlockLength);
|
||||
|
||||
if (config.debug.rhizome_tx)
|
||||
DEBUGF("src sid=%s, dst sid=%s, mdpRXWindowStart=0x%x",
|
||||
DEBUGF("src sid=%s, dst sid=%s, mdpRXWindowStart=0x%"PRIx64,
|
||||
alloca_tohex_sid(mdp.out.src.sid),alloca_tohex_sid(mdp.out.dst.sid),
|
||||
slot->write_state.file_offset + slot->write_state.data_size);
|
||||
|
||||
@ -1276,7 +1276,7 @@ static int rhizome_fetch_switch_to_mdp(struct rhizome_fetch_slot *slot)
|
||||
}
|
||||
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Trying to switch to MDP for Rhizome fetch: slot=0x%p (%d bytes)",
|
||||
DEBUGF("Trying to switch to MDP for Rhizome fetch: slot=0x%p (%"PRId64" bytes)",
|
||||
slot,slot->write_state.file_length);
|
||||
|
||||
/* close socket and stop watching it */
|
||||
@ -1538,7 +1538,7 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
|
||||
return;
|
||||
} else {
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Empty read, closing connection: received %lld of %lld bytes",
|
||||
DEBUGF("Empty read, closing connection: received %"PRId64" of %"PRId64" bytes",
|
||||
slot->write_state.file_offset + slot->write_state.data_size,slot->write_state.file_length);
|
||||
rhizome_fetch_switch_to_mdp(slot);
|
||||
return;
|
||||
@ -1590,7 +1590,7 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
|
||||
if (slot->write_state.file_length==-1)
|
||||
slot->write_state.file_length=parts.content_length;
|
||||
else if (parts.content_length != slot->write_state.file_length)
|
||||
WARNF("Expected content length %lld, got %lld", slot->write_state.file_length, parts.content_length);
|
||||
WARNF("Expected content length %"PRId64", got %"PRId64, slot->write_state.file_length, parts.content_length);
|
||||
/* We have all we need. The file is already open, so just write out any initial bytes of
|
||||
the body we read.
|
||||
*/
|
||||
|
@ -279,7 +279,7 @@ void rhizome_server_poll(struct sched_ent *alarm)
|
||||
}
|
||||
rhizome_http_request *request = calloc(sizeof(rhizome_http_request), 1);
|
||||
if (request == NULL) {
|
||||
WHYF_perror("calloc(%u, 1)", sizeof(rhizome_http_request));
|
||||
WHYF_perror("calloc(%u, 1)", (int)sizeof(rhizome_http_request));
|
||||
WHY("Cannot respond to request, out of memory");
|
||||
} else {
|
||||
request->uuid=rhizome_http_request_uuid_counter++;
|
||||
@ -366,7 +366,7 @@ int rhizome_server_sql_query_http_response(rhizome_http_request *r,
|
||||
r->buffer[r->buffer_length+1]=0x01; /* version of response */
|
||||
|
||||
if (config.debug.rhizome_tx)
|
||||
DEBUGF("Found %lld records",r->source_count);
|
||||
DEBUGF("Found %"PRId64" records",r->source_count);
|
||||
/* Number of records we intend to return */
|
||||
r->buffer[r->buffer_length+4]=(r->source_count>>0)&0xff;
|
||||
r->buffer[r->buffer_length+5]=(r->source_count>>8)&0xff;
|
||||
@ -658,7 +658,7 @@ int rhizome_server_parse_http_request(rhizome_http_request *r)
|
||||
DEBUGF("Row not found");
|
||||
rhizome_server_simple_http_response(r, 404, "<html><h1>Payload not found</h1></html>\r\n");
|
||||
} else {
|
||||
DEBUGF("row id = %d",r->rowid);
|
||||
DEBUGF("row id = %"PRId64,r->rowid);
|
||||
r->source_index = 0;
|
||||
r->blob_end = sqlite3_blob_bytes(blob);
|
||||
rhizome_server_http_response_header(r, 200, "application/binary", r->blob_end - r->source_index);
|
||||
|
@ -103,7 +103,7 @@ int rhizome_open_write(struct rhizome_write *write, char *expectedFileHash, int6
|
||||
/* Get rowid for inserted row, so that we can modify the blob */
|
||||
write->blob_rowid = sqlite3_last_insert_rowid(rhizome_db);
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Got rowid %lld for %s", write->blob_rowid, write->id);
|
||||
DEBUGF("Got rowid %"PRId64" for %s", write->blob_rowid, write->id);
|
||||
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ int rhizome_write_buffer(struct rhizome_write *write_state, unsigned char *buffe
|
||||
IN();
|
||||
/* Make sure we aren't being asked to write more data than we expected */
|
||||
if (write_state->file_offset + data_size > write_state->file_length)
|
||||
RETURN(WHYF("Too much content supplied, %lld + %d > %lld",
|
||||
RETURN(WHYF("Too much content supplied, %"PRId64" + %d > %"PRId64,
|
||||
write_state->file_offset, data_size, write_state->file_length));
|
||||
|
||||
if (data_size<=0)
|
||||
@ -212,7 +212,7 @@ int rhizome_write_buffer(struct rhizome_write *write_state, unsigned char *buffe
|
||||
SHA512_Update(&write_state->sha512_context, buffer, data_size);
|
||||
write_state->file_offset+=data_size;
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Written %lld of %lld", write_state->file_offset, write_state->file_length);
|
||||
DEBUGF("Written %"PRId64" of %"PRId64, write_state->file_offset, write_state->file_length);
|
||||
RETURN(data_size);
|
||||
OUT();
|
||||
}
|
||||
@ -509,7 +509,7 @@ int rhizome_open_read(struct rhizome_read *read, const char *fileid, int hash)
|
||||
if ((read->length = lseek(read->blob_fd, 0, SEEK_END)) == -1)
|
||||
return WHYF_perror("lseek(%s,0,SEEK_END)", alloca_str_toprint(blob_path));
|
||||
if (config.debug.externalblobs)
|
||||
DEBUGF("Opened stored file %s as fd %d, len %llx",blob_path, read->blob_fd, read->length);
|
||||
DEBUGF("Opened stored file %s as fd %d, len %"PRIx64,blob_path, read->blob_fd, read->length);
|
||||
}
|
||||
read->hash = hash;
|
||||
read->offset = 0;
|
||||
@ -532,7 +532,7 @@ int rhizome_read(struct rhizome_read *read_state, unsigned char *buffer, int buf
|
||||
if (bytes_read == -1)
|
||||
RETURN(WHYF_perror("read(%d,%p,%ld)", read_state->blob_fd, buffer, (long)buffer_length));
|
||||
if (config.debug.externalblobs)
|
||||
DEBUGF("Read %d bytes from fd %d @%llx", bytes_read, read_state->blob_fd, read_state->offset);
|
||||
DEBUGF("Read %d bytes from fd %d @%"PRIx64, bytes_read, read_state->blob_fd, read_state->offset);
|
||||
} else if (read_state->blob_rowid != -1) {
|
||||
sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT;
|
||||
do{
|
||||
@ -728,7 +728,6 @@ int rhizome_write_open_journal(struct rhizome_write *write, rhizome_manifest *m,
|
||||
uint64_t old_length = m->fileLength;
|
||||
uint64_t copy_length = old_length - advance_by;
|
||||
m->fileLength = m->fileLength + new_size - advance_by;
|
||||
DEBUGF("Before %lld, advance %lld, new %lld = %lld, %lld", old_length, advance_by, new_size, copy_length, m->fileLength);
|
||||
rhizome_manifest_set_ll(m, "filesize", m->fileLength);
|
||||
|
||||
if (advance_by>0){
|
||||
@ -744,7 +743,6 @@ int rhizome_write_open_journal(struct rhizome_write *write, rhizome_manifest *m,
|
||||
goto failure;
|
||||
|
||||
if (copy_length>0){
|
||||
DEBUGF("Copying %lld", copy_length);
|
||||
struct rhizome_read read_state;
|
||||
bzero(&read_state, sizeof read_state);
|
||||
ret = rhizome_open_decrypt_read(m, bsk, &read_state, 1);
|
||||
|
@ -74,7 +74,7 @@ static void rhizome_sync_request(struct subscriber *subscriber, uint64_t token,
|
||||
|
||||
mdp.out.payload_length = ob_position(b);
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Sending request to %s for BARs from %lld %s", alloca_tohex_sid(subscriber->sid), token, forwards?"forwards":"backwards");
|
||||
DEBUGF("Sending request to %s for BARs from %"PRIu64" %s", alloca_tohex_sid(subscriber->sid), token, forwards?"forwards":"backwards");
|
||||
overlay_mdp_dispatch(&mdp,0,NULL,0);
|
||||
ob_free(b);
|
||||
}
|
||||
@ -281,7 +281,7 @@ static void sync_process_bar_list(struct subscriber *subscriber, struct rhizome_
|
||||
added=1;
|
||||
}
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Synced %llu - %llu with %s", state->sync_start, state->sync_end, alloca_tohex_sid(subscriber->sid));
|
||||
DEBUGF("Synced %"PRIu64" - %"PRIu64" with %s", state->sync_start, state->sync_end, alloca_tohex_sid(subscriber->sid));
|
||||
if (added)
|
||||
state->next_request = gettime_ms();
|
||||
}
|
||||
@ -404,7 +404,7 @@ static void sync_send_response(struct subscriber *dest, int forwards, uint64_t t
|
||||
if (count){
|
||||
mdp.out.payload_length = ob_position(b);
|
||||
if (config.debug.rhizome)
|
||||
DEBUGF("Sending %d BARs from %llu to %llu", count, token, last);
|
||||
DEBUGF("Sending %d BARs from %"PRIu64" to %"PRIu64, count, token, last);
|
||||
overlay_mdp_dispatch(&mdp,0,NULL,0);
|
||||
}
|
||||
ob_free(b);
|
||||
|
2
slip.c
2
slip.c
@ -105,7 +105,7 @@ int slip_encode(int format,
|
||||
// Add 32-bit CRC
|
||||
// (putting the CRC at the front allows it to be calculated progressively
|
||||
// on the receiver side, if we decide to support that)
|
||||
unsigned long crc=Crc32_ComputeBuf( 0, src, src_bytes);
|
||||
uint32_t crc=Crc32_ComputeBuf( 0, src, src_bytes);
|
||||
dst[out_len++]=0x80|((crc>>25)&0x7f);
|
||||
dst[out_len++]=0x80|((crc>>(25-7))&0x7f);
|
||||
dst[out_len++]=0x80|((crc>>(25-7-7))&0x7f);
|
||||
|
Loading…
Reference in New Issue
Block a user