Skip to content

Remove unused and unread variables reported by cppcheck#3

Open
rcorsi wants to merge 1 commit into
DrPitre:mainfrom
rcorsi:remove_unused_var
Open

Remove unused and unread variables reported by cppcheck#3
rcorsi wants to merge 1 commit into
DrPitre:mainfrom
rcorsi:remove_unused_var

Conversation

@rcorsi

@rcorsi rcorsi commented May 28, 2026

Copy link
Copy Markdown
Contributor

I found these unused variables by using the cppcheck tool.

@rcorsi

rcorsi commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Here is a command line to see the already reported unused variables. I'm using cppcheck 1.19 on Ubuntu 26.04

$ cppcheck --enable=style *.c 2>&1 | grep -A 2 unusedVariable
drivewire.c:120:7: style: Unused variable: buffer [unusedVariable]
 char buffer[81];
      ^
drivewire.c:195:9: style: Unused variable: i [unusedVariable]
    int i;
        ^
--
dwprotocol.c:11:10: style: Unused variable: rfds [unusedVariable]
  fd_set rfds;
         ^
dwprotocol.c:12:18: style: Unused variable: tv [unusedVariable]
  struct timeval tv;
                 ^

I was digging a little more and found a few unreadVariables too. I'll update the PR to include these too.

$ cppcheck --enable=style *.c 2>&1 | grep -A 2 unreadVariable
dwprotocol.c:13:9: style: Variable 'timeString' is assigned a value that is never used. [unreadVariable]
  char *timeString = NULL;
        ^
--
dwwin.c:10:8: style: Variable 'y' is assigned a value that is never used. [unreadVariable]
 int y = 1;
       ^
dwwin.c:10:6: style: Variable 'y' is assigned a value that is never used. [unreadVariable]
 int y = 1;
     ^

@rcorsi
rcorsi force-pushed the remove_unused_var branch from 3d8d9a8 to 775f8f2 Compare June 6, 2026 18:38
Found with cppcheck 1.19 on Ubuntu 26.04
@rcorsi
rcorsi force-pushed the remove_unused_var branch from 775f8f2 to 6b991f6 Compare June 6, 2026 18:41
@rcorsi rcorsi changed the title Remove unused variables Remove unused and unread variables reported by cppcheck Jun 6, 2026
hathaway3 added a commit to hathaway3/DriveWire that referenced this pull request Jun 15, 2026
open_remote_stream stripped the port from the Host header, which is an
RFC 7230 violation that some HTTP servers reject or misroute. It also
returned None on any non-2xx response without logging, making a 404/400
from the remote sector server indistinguishable from an unreachable host.

Include the non-default port in the Host header, and log the actual status
line on non-2xx so remote-drive failures (defect DrPitre#2) and clone failures
(defect DrPitre#3) are diagnosable from the on-device system log.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hathaway3 added a commit to hathaway3/DriveWire that referenced this pull request Jun 15, 2026
…gation notes

Initial DEFECTS.md capturing 12 defects + 5 feature gaps for the
micropython implementation, including investigation progress and the
diagnostics added on branch fix/remote-disk-io for defects DrPitre#2 and DrPitre#3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hathaway3 added a commit to hathaway3/DriveWire that referenced this pull request Jun 15, 2026
…able data

Adds a level-2 log line when read_sector opens the socket (HTTP 2xx) but
reads fewer than the expected bytes, recording read_bytes/expected. This
pinpoints whether an on-device failure is a 404, an exception, a 0-byte
read, or a truncated read — needed to confirm the readinto-vs-recv lead
for defects DrPitre#2 and DrPitre#3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hathaway3 added a commit to hathaway3/DriveWire that referenced this pull request Jun 15, 2026
…tre#2)

The raw lwIP socket's readinto(memoryview[pos:]) did not deliver the HTTP
response body on the Pico, so every remote sector read returned no data and
the CoCo saw I/O errors — even though the server returns a correct 200 +
2048 raw bytes (confirmed via curl). The remote file-listing path, which
works on-device, reads with recv(); the broken sector/clone paths used
readinto(). Switch read_sector to recv(), capped to the bytes still needed
for the current sector so it never crosses a boundary.

Adds a reassembly test that feeds the body in 100-byte chunks straddling
sector boundaries and verifies correct per-sector reconstruction.

Toward defect DrPitre#2; clone (DrPitre#3) shares the same readinto pattern and is
addressed separately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hathaway3 added a commit to hathaway3/DriveWire that referenced this pull request Jun 15, 2026
DrPitre#3)

Same root cause as DrPitre#2: the clone download loop filled its 4KB buffer with
sock.readinto(view[pos:to_read]), which did not deliver the body on-device,
so cloning failed. Switch to recv() capped to the bytes still needed for the
current block, matching read_sector and the working file-listing paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hathaway3 added a commit to hathaway3/DriveWire that referenced this pull request Jun 15, 2026
…DrPitre#3

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hathaway3 added a commit to hathaway3/DriveWire that referenced this pull request Jun 15, 2026
Move DrPitre#1/DrPitre#5/DrPitre#6/DrPitre#7/#8/#9/#10/#11/#12 and F2 to Fixed with commit refs,
note DrPitre#2/DrPitre#3 pending on-device verification, and record why DrPitre#4 (server
listen mode) and feature gaps F1/F3/F5 are deferred to an on-device pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant