Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQgZt-00EsYt-09 for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 06:43:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQgZr-00Bte8-2G for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 06:43:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQgZr-00Bte0-1N for pgsql-hackers@lists.postgresql.org; Wed, 03 Dec 2025 06:43:03 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQgZo-002spM-3C for pgsql-hackers@lists.postgresql.org; Wed, 03 Dec 2025 06:43:02 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4eddfb8c7f5so58798851cf.1 for ; Tue, 02 Dec 2025 22:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764744180; x=1765348980; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=yyegevCNrsMS5F6LKj+oCO2GybHm/6sHUOfjdIrUziI=; b=a9pFycxL0WpRJAqlUXQkY8yE1J8AV1cLHaGXHfIstLuRri+YSghmld+ycEzpfFBQ2I 15Dr6IFhkak78uotfZtZdGmSJn1t4TzR08rhxl40dXfmTnrtU7zJyZt0+JiQpnScZsmn Cn1gqgQnFpaiAwXRk0ivg82nXBw4m6OQjxk8NaiIa64CXj/vxpL8Ki+VWnpTJ94YV0Qf EJKX1ScHScKOigXuLoPT5GFlw/n+NsNCD7dhaQNQiHLxuJt5r7Vuf5dl+mNP7HudIoAW NUC0knI6s292urkHZsfoyBv3LikZ8Yak5VvUeklSswkXOdrlu+2rbI7EA+oTSyEOrFmj vSBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764744180; x=1765348980; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yyegevCNrsMS5F6LKj+oCO2GybHm/6sHUOfjdIrUziI=; b=AXSYSbR7/UAg3u5KG+l/tcadYoQUp6iBoY58bd8+5O+875Jt896/BxZIZIdb5VY/Qm X6YN+jhQpY3P9cvQhpEZDRkTAdPUWsfXfIYF6KTyJ17tIUkRn2tAWDEBqxDRYUeDSbJK OA7Q5pfbzkbUbd6JAKr6wU2doRC+whHtccCtpJpsJo5EtbALcIhHLJHiykjZPtJcQsLY n5X6bfXoj0dgmKeSM033bFqzpS39ikVRYRtmukXtw8b3/IrPnHh7/rWAI+1yP4pF4joW WNAlu67rgfcpSSzl5psCDTCotWt2P70kD1uSXiXI12KtLEC0eoSGx41clB7hf/Wd3wid /adw== X-Forwarded-Encrypted: i=1; AJvYcCXkVLE1iEewnMOAfzCztmyEXViX0jUNR/qrrU7B8qvjBByU3S7z+xMjvfZMEU5RIVoRZSSABxg2Gtt6NzIp@lists.postgresql.org X-Gm-Message-State: AOJu0YybfqAzNwcAYvKSXlPQDhKW3HCMXAP4942WKXuEo/UycnXF9YtD L2mc2iZLBHRmYgXZHqnxJNbaxskgQ20mqzXsugtuksZCIenjKoXaYnRBmQv1C8fMVI9HRS9/6vR nQNOVUJQQoW7wBk7o6IPMBJz3oWT1L/c= X-Gm-Gg: ASbGncuYqTgWOgFleFrHVhe0Vv0GPi4w6eyE0f82FS7tZAP030myQ7SgyxBDryVbhPC E8DE+c5Ix5jL8Q/VJW+QaitRsQ+xKKL4ANP0WgE+k8A9HYjhkbZyWW042bb/qQPAd2UgEkfUzk2 SRc5tx+gog6i59bHdDxGesNhqotaMRaH8pp3RJARIA3TczOWtvctAY2mDr8dP/D6xdtbIJxep+L 2l/dBXRxcuJCE1MezdZV7TssF8EJiOeSgFuCx8lSZVXO0yXTm93d4yqiLwS000oGzrbJHJxcjbY jIiYJLChYIJse4peUPuclsQACjM= X-Google-Smtp-Source: AGHT+IERtJ7SoJLY41KjQ6wMh6PIo5qPo2CIz5M+GKvYY50GinWvL8TVPwyeAmpdX/Q5d5geR0Ls/eXuoZUjt8jjiRo= X-Received: by 2002:a05:622a:1212:b0:4ee:1875:42fa with SMTP id d75a77b69052e-4f01757fbd5mr15828131cf.1.1764744179560; Tue, 02 Dec 2025 22:42:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Wed, 3 Dec 2025 17:42:33 +1100 X-Gm-Features: AWmQ_bnFPE7jvXnSw5aKmU6MCvvYBfNwY3CcD3zLq4VQq6XaXVMalJyhj9RThNo Message-ID: Subject: Re: Cleanup shadows variable warnings, round 1 To: Chao Li Cc: Peter Eisentraut , Postgres hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Chao. I always build with the shadow warnings enabled, so I am happy someone has taken up the challenge to try to clean them up. You probably found an old thread where I tried to do the same very thing several years ago/. I had fixed most of them in my local environment, but the thread became stalled due to (a) IIUC, there was some push-back about causing too much churn, and (b) I didn't know how to break it into manageable chunks. So I wish you better luck this time. I have just started to look at your patches: ====== Patch v2-0001. src/backend/backup/basebackup_incremental.c: PrepareForIncrementalBackup: Instead of changing the var name from 'i' to 'u', you can fix this one by changing all the for loops to declare 'i' within the 'for ('. That way kills two birds with one stone: it removes the shadow warning and at the same time improves the scope of the loop variables. - int i; - for (i = 0; i < num_wal_ranges; ++i) + for (int i = 0; i < num_wal_ranges; ++i) - for (i = 0; i < num_wal_ranges; ++i) + for (int i = 0; i < num_wal_ranges; ++i) - unsigned i; - for (i = 0; i < nblocks; ++i) + for (unsigned i = 0; i < nblocks; ++i) ====== I will continue to look at the rest of the patches as time permits. ====== Kind Regards, Peter Smith. Fujitsu Australia