fix potential type mismatches between format specifiers and arguments Cast printf arguments of type time_t and off_t to long long to match the %lld format specifier on platforms where this might not be the case. In parse.y, switch the number variable to long long because all its interactions are with that type anyway. ok millert stsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
diff --git a/got/got.c b/got/got.c
index 7b11e29..d493fce 100644
--- a/got/got.c
+++ b/got/got.c
@@ -9481,11 +9481,11 @@ cat_commit(struct got_object_id *id, struct got_repository *repo, FILE *outfile)
}
fprintf(outfile, "%s%s %lld +0000\n", GOT_COMMIT_LABEL_AUTHOR,
got_object_commit_get_author(commit),
- got_object_commit_get_author_time(commit));
+ (long long)got_object_commit_get_author_time(commit));
fprintf(outfile, "%s%s %lld +0000\n", GOT_COMMIT_LABEL_COMMITTER,
got_object_commit_get_author(commit),
- got_object_commit_get_committer_time(commit));
+ (long long)got_object_commit_get_committer_time(commit));
logmsg = got_object_commit_get_logmsg_raw(commit);
fprintf(outfile, "messagelen %zd\n", strlen(logmsg));
@@ -9540,7 +9540,7 @@ cat_tag(struct got_object_id *id, struct got_repository *repo, FILE *outfile)
fprintf(outfile, "%s%s %lld +0000\n", GOT_TAG_LABEL_TAGGER,
got_object_tag_get_tagger(tag),
- got_object_tag_get_tagger_time(tag));
+ (long long)got_object_tag_get_tagger_time(tag));
tagmsg = got_object_tag_get_message(tag);
fprintf(outfile, "messagelen %zd\n", strlen(tagmsg));
diff --git a/lib/object_create.c b/lib/object_create.c
index 73b108d..a1f3f64 100644
--- a/lib/object_create.c
+++ b/lib/object_create.c
@@ -142,7 +142,7 @@ got_object_blob_file_create(struct got_object_id **id, FILE **blobfile,
}
if (asprintf(&header, "%s %lld", GOT_OBJ_LABEL_BLOB,
- sb.st_size) == -1) {
+ (long long)sb.st_size) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
@@ -438,12 +438,12 @@ got_object_commit_create(struct got_object_id **id,
}
if (asprintf(&author_str, "%s%s %lld +0000\n",
- GOT_COMMIT_LABEL_AUTHOR, author, author_time) == -1)
+ GOT_COMMIT_LABEL_AUTHOR, author, (long long)author_time) == -1)
return got_error_from_errno("asprintf");
if (asprintf(&committer_str, "%s%s %lld +0000\n",
GOT_COMMIT_LABEL_COMMITTER, committer ? committer : author,
- committer ? committer_time : author_time)
+ (long long)(committer ? committer_time : author_time))
== -1) {
err = got_error_from_errno("asprintf");
goto done;
@@ -644,7 +644,7 @@ got_object_tag_create(struct got_object_id **id,
}
if (asprintf(&tagger_str, "%s%s %lld +0000\n",
- GOT_TAG_LABEL_TAGGER, tagger, tagger_time) == -1)
+ GOT_TAG_LABEL_TAGGER, tagger, (long long)tagger_time) == -1)
return got_error_from_errno("asprintf");
msg0 = strdup(tagmsg);
diff --git a/libexec/got-index-pack/got-index-pack.c b/libexec/got-index-pack/got-index-pack.c
index 2a929a4..5288649 100644
--- a/libexec/got-index-pack/got-index-pack.c
+++ b/libexec/got-index-pack/got-index-pack.c
@@ -244,7 +244,8 @@ read_packed_object(struct got_pack *pack, struct got_indexed_object *obj,
free(data);
break;
}
- if (asprintf(&header, "%s %lld", obj_label, obj->size) == -1) {
+ if (asprintf(&header, "%s %lld", obj_label,
+ (long long)obj->size) == -1) {
err = got_error_from_errno("asprintf");
free(data);
break;
diff --git a/libexec/got-read-gotconfig/parse.y b/libexec/got-read-gotconfig/parse.y
index 2ae503c..df2c1d7 100644
--- a/libexec/got-read-gotconfig/parse.y
+++ b/libexec/got-read-gotconfig/parse.y
@@ -84,7 +84,7 @@ static const struct got_error* new_remote(struct gotconfig_remote_repo **);
typedef struct {
union {
- int64_t number;
+ long long number;
char *string;
struct node_branch *branch;
} v;