aboutsummaryrefslogtreecommitdiff
path: root/solo.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2011-04-11 17:32:44 +0000
committerSimon Tatham <anakin@pobox.com>2011-04-11 17:32:44 +0000
commit3e0822228aa4f5676b40e3911aa659676f6f4f48 (patch)
tree5fdaca1cfb5189e19b5a4446d27655656244a876 /solo.c
parent91f5f585b266d59485eb8ba27e151c545e01cb2c (diff)
downloadpuzzles-3e0822228aa4f5676b40e3911aa659676f6f4f48.zip
puzzles-3e0822228aa4f5676b40e3911aa659676f6f4f48.tar.gz
puzzles-3e0822228aa4f5676b40e3911aa659676f6f4f48.tar.bz2
puzzles-3e0822228aa4f5676b40e3911aa659676f6f4f48.tar.xz
Fix mismatch between printf format strings and arguments in some
solosolver verbose diagnostics in X mode. Also added gcc-specific prototypes with __attribute__((format)) to ensure they all get checked in future. Spotted by Arun Giridhar; segfault without this fix is reproducible by 'solosolver -v 3x3x:7_9e4_1c7d3e3d1b2_4e2c6e5_6b1d8e5d9c8_2e9_5'. [originally from svn r9151]
Diffstat (limited to 'solo.c')
-rw-r--r--solo.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/solo.c b/solo.c
index 52e89cb..8e50c3b 100644
--- a/solo.c
+++ b/solo.c
@@ -830,6 +830,24 @@ static void solver_place(struct solver_usage *usage, int x, int y, int n)
}
}
+#if defined STANDALONE_SOLVER && defined __GNUC__
+/*
+ * Forward-declare the functions taking printf-like format arguments
+ * with __attribute__((format)) so as to ensure the argument syntax
+ * gets debugged.
+ */
+struct solver_scratch;
+static int solver_elim(struct solver_usage *usage, int *indices,
+ char *fmt, ...) __attribute__((format(printf,3,4)));
+static int solver_intersect(struct solver_usage *usage,
+ int *indices1, int *indices2, char *fmt, ...)
+ __attribute__((format(printf,4,5)));
+static int solver_set(struct solver_usage *usage,
+ struct solver_scratch *scratch,
+ int *indices, char *fmt, ...)
+ __attribute__((format(printf,4,5)));
+#endif
+
static int solver_elim(struct solver_usage *usage, int *indices
#ifdef STANDALONE_SOLVER
, char *fmt, ...
@@ -2239,7 +2257,7 @@ static void solver(int cr, struct block_structure *blocks,
#ifdef STANDALONE_SOLVER
, "intersectional analysis,"
" %d in \\-diagonal vs block %s",
- n, 1+x, usage->blocks->blocknames[b]
+ n, usage->blocks->blocknames[b]
#endif
) ||
solver_intersect(usage, scratch->indexlist2,
@@ -2247,7 +2265,7 @@ static void solver(int cr, struct block_structure *blocks,
#ifdef STANDALONE_SOLVER
, "intersectional analysis,"
" %d in block %s vs \\-diagonal",
- n, usage->blocks->blocknames[b], 1+x
+ n, usage->blocks->blocknames[b]
#endif
)) {
diff = max(diff, DIFF_INTERSECT);
@@ -2272,7 +2290,7 @@ static void solver(int cr, struct block_structure *blocks,
#ifdef STANDALONE_SOLVER
, "intersectional analysis,"
" %d in /-diagonal vs block %s",
- n, 1+x, usage->blocks->blocknames[b]
+ n, usage->blocks->blocknames[b]
#endif
) ||
solver_intersect(usage, scratch->indexlist2,
@@ -2280,7 +2298,7 @@ static void solver(int cr, struct block_structure *blocks,
#ifdef STANDALONE_SOLVER
, "intersectional analysis,"
" %d in block %s vs /-diagonal",
- n, usage->blocks->blocknames[b], 1+x
+ n, usage->blocks->blocknames[b]
#endif
)) {
diff = max(diff, DIFF_INTERSECT);