Skip to content

Commit 13c7823

Browse files
author
DenverM80
committed
Fix printing of unsigned long long in a platform independant manner
1 parent 939308b commit 13c7823

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/ds3_init_requests.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
#include "ds3_request.h"
2727
#include "ds3_net.h"
2828

29+
#ifdef _WIN32
30+
#include <io.h>
31+
#ifndef PRIu64
32+
#define PRIu64 "I64u"
33+
#endif
34+
#else
35+
#include <inttypes.h>
36+
#endif
37+
2938
#define STRING_BUFFER_SIZE 32
3039

3140
static char* _get_ds3_bucket_acl_permission_str(ds3_bucket_acl_permission input) {
@@ -854,21 +863,21 @@ static void _set_query_param_flag(const ds3_request* _request, const char* key,
854863
static void _set_query_param_uint64_t(const ds3_request* _request, const char* key, uint64_t value) {
855864
char string_buffer[STRING_BUFFER_SIZE];
856865
memset(string_buffer, 0, sizeof(string_buffer));
857-
snprintf(string_buffer, sizeof(string_buffer), "%" PRIu64, value);
866+
g_snprintf(string_buffer, sizeof(string_buffer), "%" PRIu64, value);
858867
_set_query_param(_request, key, string_buffer);
859868
}
860869

861870
static void _set_query_param_int(const ds3_request* _request, const char* key, int value) {
862871
char string_buffer[STRING_BUFFER_SIZE];
863872
memset(string_buffer, 0, sizeof(string_buffer));
864-
snprintf(string_buffer, sizeof(string_buffer), "%d", value);
873+
g_snprintf(string_buffer, sizeof(string_buffer), "%d", value);
865874
_set_query_param(_request, key, string_buffer);
866875
}
867876

868877
static void _set_query_param_float(const ds3_request* _request, const char* key, float value) {
869878
char string_buffer[STRING_BUFFER_SIZE];
870879
memset(string_buffer, 0, sizeof(string_buffer));
871-
snprintf(string_buffer, sizeof(string_buffer), "%f", value);
880+
g_snprintf(string_buffer, sizeof(string_buffer), "%f", value);
872881
_set_query_param(_request, key, string_buffer);
873882
}
874883

src/ds3_requests.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828
#include "ds3_utils.h"
2929

3030
#ifdef _WIN32
31-
#include <io.h>
31+
#include <io.h>
32+
#ifndef PRIu64
33+
#define PRIu64 "I64u"
34+
#endif
3235
#else
33-
#include <inttypes.h>
36+
#include <inttypes.h>
3437
#endif
3538

3639

@@ -427,6 +430,7 @@ static xmlDocPtr _generate_xml_bulk_objects_list(const ds3_bulk_object_list_resp
427430

428431
for (obj_index = 0; obj_index < obj_list->num_objects; obj_index++) {
429432
obj = obj_list->objects[obj_index];
433+
memset(size_buff, 0, sizeof(size_buff));
430434
g_snprintf(size_buff, STRING_BUFFER_SIZE, "%" PRIu64, obj->length);
431435

432436
object_node = xmlNewNode(NULL, (xmlChar*) "Object");

0 commit comments

Comments
 (0)