"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
mark got_error_fmt as printf-like
To:
gameoftrees@openbsd.org
Date:
Tue, 19 Jul 2022 11:16:05 +0200

Download raw body.

Thread
as per subject, plus fixes some errors that arisen

diff refs/heads/main refs/heads/goterrfmt
commit - d2587c5f95c6edb51ccc8d4abfac838b58f3a463
commit + dbb13d1ba20d1b37481201cae96850e719acef50
blob - 9dcd5b85b181ee63d76a75bf16c9ae0dc46aaa26
blob + 1d0c10d78dbadca30895a068e7909856805f6496
--- include/got_error.h
+++ include/got_error.h
@@ -265,7 +265,8 @@ const struct got_error *got_error_path(const char *, i
  * from the provided format string and the variable-length list of
  * additional arguments.
 */
-const struct got_error *got_error_fmt(int, const char *, ...);
+const struct got_error *got_error_fmt(int, const char *, ...)
+	__attribute__((__format__ (printf, 2, 3)));
 
 /*
  * Check whether open(2) with O_NOFOLLOW failed on a symlink.
blob - d401d4ed9c42375d81a4e41c59a8657a274eb281
blob + dbbf1df2ebec072333fd1aaef08fac6a2f818de9
--- lib/pack_create.c
+++ lib/pack_create.c
@@ -27,6 +27,7 @@
 #include <errno.h>
 #include <stdint.h>
 #include <imsg.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -1372,7 +1373,7 @@ recv_painted_commit(void *arg, struct got_object_id *i
 	default:
 		/* should not happen */
 		return got_error_fmt(GOT_ERR_NOT_IMPL,
-		    "%s invalid commit color %d", __func__, color);
+		    "%s invalid commit color %"PRIdPTR, __func__, color);
 	}
 
 	STAILQ_FOREACH_SAFE(qid, a->ids, entry, tmp) {
@@ -1616,7 +1617,8 @@ paint_commits(int *ncolored, struct got_object_id_queu
 		default:
 			/* should not happen */
 			err = got_error_fmt(GOT_ERR_NOT_IMPL,
-			    "%s invalid commit color %d", __func__, color);
+			    "%s invalid commit color %"PRIdPTR, __func__,
+			    color);
 			goto done;
 		}
 
blob - 30401fee605c3b7937f25d1f3c8f216c945c9525
blob + 1400f75cd82a62af84447ebaeee062b963f74f31
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -21,6 +21,7 @@
 #include <sys/time.h>
 #include <sys/mman.h>
 
+#include <inttypes.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdint.h>
@@ -1663,7 +1664,8 @@ paint_commits(struct got_object_id_queue *ids, int *ni
 		default:
 			/* should not happen */
 			err = got_error_fmt(GOT_ERR_NOT_IMPL,
-			    "%s invalid commit color %d", __func__, color);
+			    "%s invalid commit color %"PRIdPTR, __func__,
+			    color);
 			goto done;
 		}