Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/atf/dist Format string annotations and fixes fo...
details: https://anonhg.NetBSD.org/src/rev/2ec4c7630029
branches: trunk
changeset: 325799:2ec4c7630029
user: joerg <joerg%NetBSD.org@localhost>
date: Tue Jan 07 02:06:42 2014 +0000
description:
Format string annotations and fixes for resulting fallout.
diffstat:
external/bsd/atf/dist/atf-c++/tests.cpp | 2 +-
external/bsd/atf/dist/atf-c/detail/dynstr.c | 1 +
external/bsd/atf/dist/atf-c/detail/dynstr.h | 18 +++++++---
external/bsd/atf/dist/atf-c/detail/fs.c | 3 +-
external/bsd/atf/dist/atf-c/detail/fs.h | 13 +++++--
external/bsd/atf/dist/atf-c/detail/sanity.c | 2 +
external/bsd/atf/dist/atf-c/detail/test_helpers.c | 4 +-
external/bsd/atf/dist/atf-c/detail/text.h | 7 +++-
external/bsd/atf/dist/atf-c/detail/tp_main.c | 1 +
external/bsd/atf/dist/atf-c/error.h | 4 +-
external/bsd/atf/dist/atf-c/tc.c | 36 +++++++++++++++-------
external/bsd/atf/dist/atf-c/tc.h | 3 +-
12 files changed, 64 insertions(+), 30 deletions(-)
diffs (truncated from 313 to 300 lines):
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c++/tests.cpp
--- a/external/bsd/atf/dist/atf-c++/tests.cpp Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c++/tests.cpp Tue Jan 07 02:06:42 2014 +0000
@@ -269,7 +269,7 @@
void
impl::tc::set_md_var(const std::string& var, const std::string& val)
{
- atf_error_t err = atf_tc_set_md_var(&pimpl->m_tc, var.c_str(), val.c_str());
+ atf_error_t err = atf_tc_set_md_var(&pimpl->m_tc, var.c_str(), "%s", val.c_str());
if (atf_is_error(err))
throw_atf_error(err);
}
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/dynstr.c
--- a/external/bsd/atf/dist/atf-c/detail/dynstr.c Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/dynstr.c Tue Jan 07 02:06:42 2014 +0000
@@ -67,6 +67,7 @@
return err;
}
+ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0)
static
atf_error_t
prepend_or_append(atf_dynstr_t *ad, const char *fmt, va_list ap,
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/dynstr.h
--- a/external/bsd/atf/dist/atf-c/detail/dynstr.h Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/dynstr.h Tue Jan 07 02:06:42 2014 +0000
@@ -52,8 +52,10 @@
/* Constructors and destructors */
atf_error_t atf_dynstr_init(atf_dynstr_t *);
-atf_error_t atf_dynstr_init_ap(atf_dynstr_t *, const char *, va_list);
-atf_error_t atf_dynstr_init_fmt(atf_dynstr_t *, const char *, ...);
+atf_error_t atf_dynstr_init_ap(atf_dynstr_t *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
+atf_error_t atf_dynstr_init_fmt(atf_dynstr_t *, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
atf_error_t atf_dynstr_init_raw(atf_dynstr_t *, const void *, size_t);
atf_error_t atf_dynstr_init_rep(atf_dynstr_t *, size_t, char);
atf_error_t atf_dynstr_init_substr(atf_dynstr_t *, const atf_dynstr_t *,
@@ -68,11 +70,15 @@
size_t atf_dynstr_rfind_ch(const atf_dynstr_t *, char);
/* Modifiers */
-atf_error_t atf_dynstr_append_ap(atf_dynstr_t *, const char *, va_list);
-atf_error_t atf_dynstr_append_fmt(atf_dynstr_t *, const char *, ...);
+atf_error_t atf_dynstr_append_ap(atf_dynstr_t *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
+atf_error_t atf_dynstr_append_fmt(atf_dynstr_t *, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
void atf_dynstr_clear(atf_dynstr_t *);
-atf_error_t atf_dynstr_prepend_ap(atf_dynstr_t *, const char *, va_list);
-atf_error_t atf_dynstr_prepend_fmt(atf_dynstr_t *, const char *, ...);
+atf_error_t atf_dynstr_prepend_ap(atf_dynstr_t *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
+atf_error_t atf_dynstr_prepend_fmt(atf_dynstr_t *, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
/* Operators */
bool atf_equal_dynstr_cstring(const atf_dynstr_t *, const char *);
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/fs.c
--- a/external/bsd/atf/dist/atf-c/detail/fs.c Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/fs.c Tue Jan 07 02:06:42 2014 +0000
@@ -63,7 +63,8 @@
static mode_t current_umask(void);
static atf_error_t do_mkdtemp(char *);
static atf_error_t normalize(atf_dynstr_t *, char *);
-static atf_error_t normalize_ap(atf_dynstr_t *, const char *, va_list);
+static atf_error_t normalize_ap(atf_dynstr_t *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
static void replace_contents(atf_fs_path_t *, const char *);
static const char *stat_type_to_string(const int);
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/fs.h
--- a/external/bsd/atf/dist/atf-c/detail/fs.h Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/fs.h Tue Jan 07 02:06:42 2014 +0000
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include <stdbool.h>
+#include <atf-c/defs.h>
#include <atf-c/error_fwd.h>
#include "dynstr.h"
@@ -50,8 +51,10 @@
typedef struct atf_fs_path atf_fs_path_t;
/* Constructors/destructors. */
-atf_error_t atf_fs_path_init_ap(atf_fs_path_t *, const char *, va_list);
-atf_error_t atf_fs_path_init_fmt(atf_fs_path_t *, const char *, ...);
+atf_error_t atf_fs_path_init_ap(atf_fs_path_t *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
+atf_error_t atf_fs_path_init_fmt(atf_fs_path_t *, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
atf_error_t atf_fs_path_copy(atf_fs_path_t *, const atf_fs_path_t *);
void atf_fs_path_fini(atf_fs_path_t *);
@@ -63,8 +66,10 @@
bool atf_fs_path_is_root(const atf_fs_path_t *);
/* Modifiers. */
-atf_error_t atf_fs_path_append_ap(atf_fs_path_t *, const char *, va_list);
-atf_error_t atf_fs_path_append_fmt(atf_fs_path_t *, const char *, ...);
+atf_error_t atf_fs_path_append_ap(atf_fs_path_t *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
+atf_error_t atf_fs_path_append_fmt(atf_fs_path_t *, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
atf_error_t atf_fs_path_append_path(atf_fs_path_t *, const atf_fs_path_t *);
atf_error_t atf_fs_path_to_absolute(const atf_fs_path_t *, atf_fs_path_t *);
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/sanity.c
--- a/external/bsd/atf/dist/atf-c/detail/sanity.c Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/sanity.c Tue Jan 07 02:06:42 2014 +0000
@@ -36,8 +36,10 @@
#include <stdio.h>
#include <stdlib.h>
+#include <atf-c/defs.h>
#include "sanity.h"
+ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
static
void
fail(const char *fmt, ...)
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/test_helpers.c
--- a/external/bsd/atf/dist/atf-c/detail/test_helpers.c Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/test_helpers.c Tue Jan 07 02:06:42 2014 +0000
@@ -131,8 +131,8 @@
atf_process_child_t child;
atf_process_status_t status;
- RE(atf_fs_path_init_fmt(&outpath, outname));
- RE(atf_fs_path_init_fmt(&errpath, errname));
+ RE(atf_fs_path_init_fmt(&outpath, "%s", outname));
+ RE(atf_fs_path_init_fmt(&errpath, "%s", errname));
struct run_h_tc_data data = { tc, resname };
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/text.h
--- a/external/bsd/atf/dist/atf-c/detail/text.h Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/text.h Tue Jan 07 02:06:42 2014 +0000
@@ -34,14 +34,17 @@
#include <stdbool.h>
#include <atf-c/error_fwd.h>
+#include <atf-c/defs.h>
#include "list.h"
atf_error_t atf_text_for_each_word(const char *, const char *,
atf_error_t (*)(const char *, void *),
void *);
-atf_error_t atf_text_format(char **, const char *, ...);
-atf_error_t atf_text_format_ap(char **, const char *, va_list);
+atf_error_t atf_text_format(char **, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
+atf_error_t atf_text_format_ap(char **, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
atf_error_t atf_text_split(const char *, const char *, atf_list_t *);
atf_error_t atf_text_to_bool(const char *, bool *);
atf_error_t atf_text_to_long(const char *, long *);
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/detail/tp_main.c
--- a/external/bsd/atf/dist/atf-c/detail/tp_main.c Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/detail/tp_main.c Tue Jan 07 02:06:42 2014 +0000
@@ -88,6 +88,7 @@
snprintf(buf, buflen, "%s", data->m_what); \
} \
\
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2) \
static \
atf_error_t \
name ## _error(const char *fmt, ...) \
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/error.h
--- a/external/bsd/atf/dist/atf-c/error.h Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/error.h Tue Jan 07 02:06:42 2014 +0000
@@ -33,6 +33,7 @@
#include <stdbool.h>
#include <stddef.h>
+#include <atf-c/defs.h>
#include <atf-c/error_fwd.h>
/* ---------------------------------------------------------------------
@@ -62,7 +63,8 @@
* Common error types.
* --------------------------------------------------------------------- */
-atf_error_t atf_libc_error(int, const char *, ...);
+atf_error_t atf_libc_error(int, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
int atf_libc_error_code(const atf_error_t);
const char *atf_libc_error_msg(const atf_error_t);
diff -r 1da99a04f42b -r 2ec4c7630029 external/bsd/atf/dist/atf-c/tc.c
--- a/external/bsd/atf/dist/atf-c/tc.c Tue Jan 07 01:59:36 2014 +0000
+++ b/external/bsd/atf/dist/atf-c/tc.c Tue Jan 07 02:06:42 2014 +0000
@@ -79,12 +79,14 @@
static void context_init(struct context *, const atf_tc_t *, const char *);
static void check_fatal_error(atf_error_t);
static void report_fatal_error(const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 2)
ATF_DEFS_ATTRIBUTE_NORETURN;
static atf_error_t write_resfile(const int, const char *, const int,
const atf_dynstr_t *);
static void create_resfile(const char *, const char *, const int,
atf_dynstr_t *);
static void error_in_expect(struct context *, const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3)
ATF_DEFS_ATTRIBUTE_NORETURN;
static void validate_expect(struct context *);
static void expected_failure(struct context *, atf_dynstr_t *)
@@ -97,9 +99,11 @@
static void skip(struct context *, atf_dynstr_t *)
ATF_DEFS_ATTRIBUTE_NORETURN;
static void format_reason_ap(atf_dynstr_t *, const char *, const size_t,
- const char *, va_list);
+ const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(4, 0);
static void format_reason_fmt(atf_dynstr_t *, const char *, const size_t,
- const char *, ...);
+ const char *, ...)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(4, 5);
static void errno_test(struct context *, const char *, const size_t,
const int, const char *, const bool,
void (*)(struct context *, atf_dynstr_t *));
@@ -571,7 +575,7 @@
if (atf_is_error(err))
goto err_vars;
- err = atf_tc_set_md_var(tc, "ident", ident);
+ err = atf_tc_set_md_var(tc, "ident", "%s", ident);
if (atf_is_error(err))
goto err_map;
@@ -787,28 +791,35 @@
* --------------------------------------------------------------------- */
static void _atf_tc_fail(struct context *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0)
ATF_DEFS_ATTRIBUTE_NORETURN;
-static void _atf_tc_fail_nonfatal(struct context *, const char *, va_list);
+static void _atf_tc_fail_nonfatal(struct context *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
static void _atf_tc_fail_check(struct context *, const char *, const size_t,
- const char *, va_list);
+ const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(4, 0);
static void _atf_tc_fail_requirement(struct context *, const char *,
- const size_t, const char *, va_list) ATF_DEFS_ATTRIBUTE_NORETURN;
+ const size_t, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_NORETURN
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(4, 0);
static void _atf_tc_pass(struct context *) ATF_DEFS_ATTRIBUTE_NORETURN;
static void _atf_tc_require_prog(struct context *, const char *);
static void _atf_tc_skip(struct context *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0)
ATF_DEFS_ATTRIBUTE_NORETURN;
static void _atf_tc_check_errno(struct context *, const char *, const size_t,
const int, const char *, const bool);
static void _atf_tc_require_errno(struct context *, const char *, const size_t,
const int, const char *, const bool);
static void _atf_tc_expect_pass(struct context *);
-static void _atf_tc_expect_fail(struct context *, const char *, va_list);
+static void _atf_tc_expect_fail(struct context *, const char *, va_list)
+ ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
static void _atf_tc_expect_exit(struct context *, const int, const char *,
- va_list);
+ va_list) ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 0);
static void _atf_tc_expect_signal(struct context *, const int, const char *,
- va_list);
+ va_list) ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(3, 0);
static void _atf_tc_expect_death(struct context *, const char *,
- va_list);
+ va_list) ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0);
static void
_atf_tc_fail(struct context *ctx, const char *fmt, va_list ap)
@@ -982,6 +993,7 @@
create_resfile(ctx->resfile, "expected_death", -1, &formatted);
}
+ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 0)
static void
_atf_tc_expect_timeout(struct context *ctx, const char *reason, va_list ap)
{
@@ -1016,13 +1028,13 @@
if (Current.fail_count > 0) {
atf_dynstr_t reason;
- format_reason_fmt(&reason, NULL, 0, "%d checks failed; see output for "
+ format_reason_fmt(&reason, NULL, 0, "%zu checks failed; see output for "
"more details", Current.fail_count);
fail_requirement(&Current, &reason);
} else if (Current.expect_fail_count > 0) {
atf_dynstr_t reason;
- format_reason_fmt(&reason, NULL, 0, "%d checks failed as expected; "
+ format_reason_fmt(&reason, NULL, 0, "%zu checks failed as expected; "
"see output for more details", Current.expect_fail_count);
expected_failure(&Current, &reason);
} else {
Home |
Main Index |
Thread Index |
Old Index