[PATCH 1/2] ccli: cache: Fix -Wuninitialized warning
Ammar Faizi <[email protected]> Thu, 21 Aug 2025 04:14:33 +0700
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
The idx variable is uninitialized and incremented. Clang warns it:
cache.c:214:28: warning: variable 'idx' is uninitialized when used here [-Wuninitialized]
214 | for (i = 0; i < cnt; i++, idx++) {
| ^~~
cache.c:184:9: note: initialize the variable 'idx' to silence this warning
184 | int idx;
| ^
| = 0
Remove the idx variable entierly, it's not used.
Co-authored-by: Alviro Iskandar Setiawan <[email protected]>
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
src/cache.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/cache.c b/src/cache.c
index 010ddbd1e722..97a24066bf69 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -181,7 +181,6 @@ __hidden int cache_save_fd(struct ccli *ccli, const char *start_tag,
char *str;
char buf[64];
int ret;
- int idx;
int i;
if (!ccli || !tag || !start_tag || !callback || fd < 0) {
@@ -211,7 +210,7 @@ __hidden int cache_save_fd(struct ccli *ccli, const char *start_tag,
if (ret < strlen(buf))
return -1;
- for (i = 0; i < cnt; i++, idx++) {
+ for (i = 0; i < cnt; i++) {
if (callback(ccli, fd, i, cnt, data) < 0)
break;
}
--
Ammar Faizi