5 snprintf(x
, sizeof(x
), "bar"); // expected-error {{Use SprintfLiteral instead of snprintf when writing into a character array.}} expected-note {{This will prevent passing in the wrong size to snprintf accidentally.}}
6 snprintf(x
, 100, "bar"); // expected-error {{Use SprintfLiteral instead of snprintf when writing into a character array.}} expected-note {{This will prevent passing in the wrong size to snprintf accidentally.}}
7 const int hundred
= 100;
8 snprintf(x
, hundred
, "bar"); // expected-error {{Use SprintfLiteral instead of snprintf when writing into a character array.}} expected-note {{This will prevent passing in the wrong size to snprintf accidentally.}}
14 snprintf(x
, sizeof(y
), "foo");
16 snprintf(x
, 50, "foo");
20 snprintf(x
, nothundred
, "foo");
23 void vargs_bad(va_list args
) {
25 vsnprintf(x
, sizeof(x
), "bar", args
); // expected-error {{Use VsprintfLiteral instead of vsnprintf when writing into a character array.}} expected-note {{This will prevent passing in the wrong size to vsnprintf accidentally.}}
26 vsnprintf(x
, 100, "bar", args
); // expected-error {{Use VsprintfLiteral instead of vsnprintf when writing into a character array.}} expected-note {{This will prevent passing in the wrong size to vsnprintf accidentally.}}
27 const int hundred
= 100;
28 vsnprintf(x
, hundred
, "bar", args
); // expected-error {{Use VsprintfLiteral instead of vsnprintf when writing into a character array.}} expected-note {{This will prevent passing in the wrong size to vsnprintf accidentally.}}
31 void vargs_good(va_list args
) {
34 vsnprintf(x
, sizeof(y
), "foo", args
);
36 vsnprintf(x
, 50, "foo", args
);
40 vsnprintf(x
, nothundred
, "foo", args
);