Sarthak-Pandey commented on PR #20627:
URL: https://github.com/apache/nuttx/pull/20627#issuecomment-6251007417

   Thank you for the constructive review and suggestions! I have revised and 
optimized all the highlighted areas:
   
   1. **De-duplicate `FIN_WAIT` blocks (`tcp_input.c`)**:
      - Replaced the duplicate 34-line data-handling block in `TCP_FIN_WAIT_1` 
with a clean `/* Fall through */` into `TCP_FIN_WAIT_2` after processing the 
FIN check and state transition.
   
   2. **De-duplicate `tcp_urg_input()` branches (`tcp_input.c`)**:
      - Refactored `tcp_urg_input()` so that both branches (`TCP_URG` flag 
announcement and pending `TCP_URG_AWAITING` capture) only determine 
`urg_offset` and set `has_urg = true`.
      - Unified the ~20 lines of common payload copyout (`iob_copyout`), state 
update (`TCP_URG_VALID`), event flagging (`TCP_URGDATA`), and byte extraction 
(`tcp_remove_urgbyte()`) into a single shared execution block.
   
   3. **Remove write-only `dev->d_urglen` (`tcp_input.c`)**:
      - Cleaned up the redundant `dev->d_urglen = 0;` assignments across all 
three branches since urgent data tracking is now fully handled via 
`conn->urg_data` and `conn->urg_state`.
   
   4. **Unconditional `sq_addlast()` (`tcp_send_buffered.c`)**:
      - Moved `sq_addlast(&wrb->wb_node, &conn->write_q);` outside the `#ifdef 
CONFIG_NET_TCPURGDATA` block so it is executed unconditionally once.
   
   5. **Unified `tcp_send()` calls (`tcp_appsend.c`)**:
      - Declared `uint16_t sendflags = TCP_ACK | TCP_PSH;` unconditionally.
      - Conditionally appended `TCP_URG` when `conn->urg_offset > 0`.
      - Unified the retransmission and normal transmit `tcp_send()` invocations 
into clean, single calls without wrapping `#ifdef` blocks.
   
   All changes have been validated:
   - `nxstyle` checks pass with 0 errors / 0 warnings.
   - CodeRabbit review completed with 0 findings.
   - Net reduction: -75 lines of redundant code (`+27 / -102`).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to