Commit b176669
websocket_handler: dedupe send_ping / send_pong scaffolding
Both functions had byte-identical bodies aside from the MHD encode
function called (MHD_websocket_encode_ping vs _pong, identical
signatures). Extract a shared `send_control_frame` static helper
parameterised on the encoder via decltype so the function-pointer
type matches MHD's `enum MHD_WEBSOCKET_STATUS` return without
restating it; a static_assert pins the ping/pong signature invariant
in case MHD ever diverges them.
Caught by `make lint-duplication` at CPD_MIN_TOKENS=50 (7 lines / 59
tokens). Below the day-1 gate at 100 tokens, but worth fixing since
the dedup is trivial and the original was a verbatim copy.
Build is unchanged on platforms without HAVE_WEBSOCKET (whole block
is still under the existing #ifdef).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9527b98 commit b176669
1 file changed
Lines changed: 26 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
97 | 111 | | |
98 | 112 | | |
99 | | - | |
100 | | - | |
| 113 | + | |
| 114 | + | |
101 | 115 | | |
102 | 116 | | |
103 | 117 | | |
104 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
105 | 125 | | |
106 | 126 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 127 | + | |
| 128 | + | |
113 | 129 | | |
114 | 130 | | |
115 | 131 | | |
| |||
0 commit comments