Skip to content

Commit 0db0db8

Browse files
fabiobaltierihenrikbrixandersen
authored andcommitted
tests: cbprintf: fix few shadowed variables
Rename few local variables that were shadowing object ones with the same name. Allows building with -Wshadow. Signed-off-by: Fabio Baltieri <[email protected]>
1 parent 3ced42c commit 0db0db8

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tests/unit/cbprintf/main.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,20 @@ static inline void reset_out(void)
153153
outbuf.idx = 0;
154154
}
155155

156-
static void outbuf_null_terminate(struct out_buffer *outbuf)
156+
static void outbuf_null_terminate(struct out_buffer *out_buf)
157157
{
158-
int idx = outbuf->idx - ((outbuf->idx == outbuf->size) ? 1 : 0);
158+
int idx = out_buf->idx - ((out_buf->idx == out_buf->size) ? 1 : 0);
159159

160-
outbuf->buf[idx] = 0;
160+
out_buf->buf[idx] = 0;
161161
}
162162

163163
static int out(int c, void *dest)
164164
{
165165
int rv = EOF;
166-
struct out_buffer *buf = dest;
166+
struct out_buffer *out_buf = dest;
167167

168-
if (buf->idx < buf->size) {
169-
buf->buf[buf->idx++] = (char)(unsigned char)c;
168+
if (out_buf->idx < out_buf->size) {
169+
out_buf->buf[out_buf->idx++] = (char)(unsigned char)c;
170170
rv = (int)(unsigned char)c;
171171
}
172172
return rv;
@@ -631,11 +631,11 @@ ZTEST(prf, test_x_length)
631631

632632
if (IS_ENABLED(CONFIG_CBPRINTF_FULL_INTEGRAL)
633633
&& (sizeof(long long) > sizeof(int))) {
634-
unsigned long long min = 0x8c7c6c5c4c3c2c1cULL;
635-
unsigned long long max = 0x8d7d6d5d4d3d2d1dULL;
634+
unsigned long long ull_min = 0x8c7c6c5c4c3c2c1cULL;
635+
unsigned long long ull_max = 0x8d7d6d5d4d3d2d1dULL;
636636

637-
TEST_PRF(&rc, "%llx/%llX", (unsigned long long)min,
638-
(unsigned long long)max);
637+
TEST_PRF(&rc, "%llx/%llX", (unsigned long long)ull_min,
638+
(unsigned long long)ull_max);
639639
PRF_CHECK("8c7c6c5c4c3c2c1c/8D7D6D5D4D3D2D1D", rc);
640640
}
641641
}
@@ -1156,17 +1156,17 @@ ZTEST(prf, test_cbprintf_package)
11561156
/* Capture the base package information for future tests. */
11571157
size_t len = rc;
11581158
/* Create a buffer aligned to max argument. */
1159-
uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) buf[len + PKG_ALIGN_OFFSET];
1159+
uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) out_buf[len + PKG_ALIGN_OFFSET];
11601160

11611161
/* Verify we get same length when storing. Pass buffer which may be
11621162
* unaligned. Same alignment offset was used for space calculation.
11631163
*/
1164-
rc = cbprintf_package(&buf[PKG_ALIGN_OFFSET], len, PACKAGE_FLAGS, fmt, 3);
1164+
rc = cbprintf_package(&out_buf[PKG_ALIGN_OFFSET], len, PACKAGE_FLAGS, fmt, 3);
11651165
zassert_equal(rc, len);
11661166

11671167
/* Verify we get an error if can't store */
11681168
len -= 1;
1169-
rc = cbprintf_package(&buf[PKG_ALIGN_OFFSET], len, PACKAGE_FLAGS, fmt, 3);
1169+
rc = cbprintf_package(&out_buf[PKG_ALIGN_OFFSET], len, PACKAGE_FLAGS, fmt, 3);
11701170
zassert_equal(rc, -ENOSPC);
11711171
}
11721172

0 commit comments

Comments
 (0)