Commit 064301cc by Shawn O. Pearce

Fix size_t snprintf warning by using PRIuPTR format macro

This is the correct C99 format code for the size_t type when passed
as an argument to the *printf family.  If the platform doesn't
define it, we assume %lu and just cross our fingers that its the
proper setting for a size_t on this system.  On most sane platforms,
"unsigned long" is the underlying type of "size_t".

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
parent a1d34bc0
......@@ -8,12 +8,17 @@
#ifdef GIT_HAS_PTHREAD
# include <pthread.h>
#endif
#include <inttypes.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifndef PRIuPTR
# define PRIuPTR "lu"
#endif
#include "git/common.h"
#define GIT_PATH_MAX 4096
......
......@@ -88,7 +88,7 @@ int git_obj__loose_object_type(git_otype type)
static int format_object_header(char *hdr, size_t n, git_obj *obj)
{
const char *type_str = git_obj_type_to_string(obj->type);
int len = snprintf(hdr, n, "%s %u", type_str, obj->len);
int len = snprintf(hdr, n, "%s %" PRIuPTR, type_str, obj->len);
assert(len > 0); /* otherwise snprintf() is broken */
assert(len < n); /* otherwise the caller is broken! */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment