public inbox for gwml@vger.gnuweeb.org
 help / color / mirror / Atom feed
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ammar Faizi <ammarfaizi2@gnuweeb.org>,
	Linux Trace Devel Mailing List
	<linux-trace-devel@vger.kernel.org>,
	GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>,
	Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Subject: [PATCH 1/2] ccli: cache: Fix -Wuninitialized warning
Date: Thu, 21 Aug 2025 04:14:33 +0700	[thread overview]
Message-ID: <20250820211434.1857859-2-ammarfaizi2@gnuweeb.org> (raw)
In-Reply-To: <20250820211434.1857859-1-ammarfaizi2@gnuweeb.org>

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 <alviro.iskandar@gnuweeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 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


  reply	other threads:[~2025-08-20 21:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-20 21:14 [PATCH 0/2] ccli: Two small fixes for ccli Ammar Faizi
2025-08-20 21:14 ` Ammar Faizi [this message]
2025-08-20 21:14 ` [PATCH 2/2] ccli: commands: Fix optimized `strlen()` calls Ammar Faizi
2025-08-21  0:12 ` [PATCH 0/2] ccli: Two small fixes for ccli Steven Rostedt
2025-08-21  0:15   ` Ammar Faizi
2025-08-21  0:18     ` Steven Rostedt
2025-08-21  0:23       ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250820211434.1857859-2-ammarfaizi2@gnuweeb.org \
    --to=ammarfaizi2@gnuweeb.org \
    --cc=alviro.iskandar@gnuweeb.org \
    --cc=gwml@vger.gnuweeb.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox