Fix MISRA rule 8.4 in common code
[project/bcm63xx/atf.git] / lib / stdlib / sscanf.c
1 /*
2 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <stdio.h>
8 #include <sys/cdefs.h>
9
10 /*
11 * TODO: This is not a real implementation of the sscanf() function. It just
12 * returns the number of expected arguments based on the number of '%' found
13 * in the format string.
14 */
15 int
16 sscanf(const char *__restrict str, char const *__restrict fmt, ...)
17 {
18 int ret = 0;
19
20 while (*fmt != '\0') {
21 if (*fmt++ == '%') {
22 ret++;
23 }
24 }
25
26 return ret;
27 }