Skip to content

Commit 4e904dd

Browse files
committed
C++: Repair the test.
1 parent eed2aee commit 4e904dd

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
| printf.cpp:39:29:39:35 | test | This argument should be of type 'wchar_t *' but is of type 'char16_t *' |
2-
| printf.cpp:45:29:45:35 | test | This argument should be of type 'char *' but is of type 'char16_t *' |
1+
| printf.cpp:24:31:24:37 | test | This argument should be of type 'char *' but is of type 'char16_t *' |
2+
| printf.cpp:36:29:36:35 | test | This argument should be of type 'char *' but is of type 'char16_t *' |
3+
| printf.cpp:43:29:43:35 | test | This argument should be of type 'char16_t *' but is of type 'wchar_t *' |
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
| printf.cpp:26:5:26:11 | sprintf | char | wchar_t | wchar_t |
1+
| printf.cpp:15:5:15:12 | swprintf | char | char16_t | char16_t |
2+
| printf.cpp:17:5:17:11 | sprintf | char | char16_t | char16_t |

cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Linux_two_byte_wprintf/printf.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,7 @@ int vswprintf(WCHAR *dest, WCHAR *format, va_list args) {
1212
return 0;
1313
}
1414

15-
int swprintf(WCHAR *dest, WCHAR *format, ...) {
16-
va_list args;
17-
va_start(args, format);
18-
19-
int ret = vswprintf(dest, format, args);
20-
21-
va_end(args);
22-
23-
return ret;
24-
}
15+
int swprintf(WCHAR *dest, WCHAR *format, ...);
2516

2617
int sprintf(char *dest, char *format, ...);
2718

@@ -30,13 +21,13 @@ int sprintf(char *dest, char *format, ...);
3021
void test1() {
3122
WCHAR string[20];
3223

33-
swprintf(string, u"test %s", u"test"); // BAD: `char16_t` string parameter read as `char` string [NOT DETECTED]
24+
swprintf(string, u"test %s", u"test"); // BAD: `char16_t` string parameter read as `char` string
3425
}
3526

3627
void test2() {
3728
char string[20];
3829

39-
sprintf(string, "test %S", u"test"); // GOOD [FALSE POSITIVE]
30+
sprintf(string, "test %S", u"test"); // GOOD
4031
}
4132

4233
void test3() {
@@ -49,5 +40,5 @@ void test3() {
4940
void test4() {
5041
char string[20];
5142

52-
sprintf(string, "test %S", L"test"); // BAD: `wchar_t` string parameter read as `char16_t` string [NOT DETECTED]
43+
sprintf(string, "test %S", L"test"); // BAD: `wchar_t` string parameter read as `char16_t` string
5344
}

0 commit comments

Comments
 (0)