Skip to content

Commit c05e355

Browse files
etrclaude
andcommitted
Fix CI: -Werror=type-limits and accumulated cpplint errors
When TASK-003..008 were merged into feature/v2.0 they were not pushed individually, so the cumulative push surfaced regressions across the matrix. This sweeps them up. Build error (basic ubuntu / valgrind / windows-IWYU): - test/unit/body_test.cpp:56-60: static_cast<int>(uint8_t-enum) >= 0 is always-true, breaking -Werror=type-limits. Replace with enumerator != body_kind::empty so the compile-time reference still guards against a missing enumerator without the bogus comparison. cpplint (17 errors → 0): - Include order: - src/details/body.cpp, src/iovec_response.cpp, src/httpserver/details/body.hpp, test/unit/{body_test,header_hygiene_test,http_method_test, iovec_entry_test}.cpp: move <microhttpd.h> and <sys/uio.h> into the C-system-header group so the layout is primary, c, c++, other. - Missing includes: - src/details/body.cpp, src/iovec_response.cpp: add <string> for std::string in the file_body / iovec_response signatures. - src/iovec_response.cpp: add <utility> for std::move. - Header guard: - src/httpserver/details/body.hpp: cpplint expects #ifndef GUARD as the first non-comment line. Move the SRC_HTTPSERVER_DETAILS_BODY_HPP_ guard above the HTTPSERVER_COMPILATION #error block (which now lives inside the guard). - Misc: - body_kind.hpp: NOLINT(build/include_what_you_use) on the `string` enumerator (cpplint mistook it for std::string). - body_test.cpp:251: split single-line if-with-multiple-statements. - http_method_test.cpp:121: add space between [] and { in lambda. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6388623 commit c05e355

8 files changed

Lines changed: 37 additions & 25 deletions

File tree

src/details/body.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "httpserver/details/body.hpp"
2222

2323
#include <fcntl.h>
24+
#include <microhttpd.h>
2425
#include <sys/stat.h>
2526
#include <sys/types.h>
2627
#include <sys/uio.h>
@@ -29,11 +30,10 @@
2930
#include <cstddef>
3031
#include <cstdint>
3132
#include <limits>
33+
#include <string>
3234
#include <type_traits>
3335
#include <utility>
3436

35-
#include <microhttpd.h>
36-
3737
namespace httpserver {
3838

3939
namespace detail {

src/httpserver/body_kind.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace httpserver {
4545
// name the enumerators).
4646
enum class body_kind : std::uint8_t {
4747
empty,
48-
string,
48+
string, // NOLINT(build/include_what_you_use) - enumerator, not std::string
4949
file,
5050
iovec,
5151
pipe,

src/httpserver/details/body.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@
2828
//
2929
// Header-hygiene contract: only library .cpp files (and build-tree unit
3030
// tests compiled with -DHTTPSERVER_COMPILATION) may include this file.
31+
#ifndef SRC_HTTPSERVER_DETAILS_BODY_HPP_
32+
#define SRC_HTTPSERVER_DETAILS_BODY_HPP_
33+
3134
#ifndef HTTPSERVER_COMPILATION
3235
#error "details/body.hpp is internal; build with -DHTTPSERVER_COMPILATION."
3336
#endif
3437

35-
#ifndef SRC_HTTPSERVER_DETAILS_BODY_HPP_
36-
#define SRC_HTTPSERVER_DETAILS_BODY_HPP_
37-
38+
#include <microhttpd.h>
3839
#include <sys/types.h> // ssize_t
40+
#include <sys/uio.h> // private header may include POSIX scatter/gather
41+
3942
#include <cassert>
4043
#include <cstddef>
4144
#include <cstdint>
@@ -44,9 +47,6 @@
4447
#include <utility>
4548
#include <vector>
4649

47-
#include <microhttpd.h>
48-
#include <sys/uio.h> // private header may include POSIX scatter/gather
49-
5050
#include "httpserver/body_kind.hpp"
5151
#include "httpserver/iovec_entry.hpp"
5252

src/iovec_response.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@
1919
*/
2020

2121
#include "httpserver/iovec_response.hpp"
22-
#include "httpserver/iovec_entry.hpp"
2322

24-
#include <cstddef>
25-
#include <limits>
2623
#include <microhttpd.h>
2724
#include <sys/uio.h>
25+
26+
#include <cstddef>
27+
#include <limits>
28+
#include <string>
2829
#include <type_traits>
30+
#include <utility>
2931
#include <vector>
3032

33+
#include "httpserver/iovec_entry.hpp"
34+
3135
struct MHD_Response;
3236

3337
namespace httpserver {

test/unit/body_test.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
// details/body.hpp directly (for the subclasses) — header-hygiene from
2525
// the consumer perspective is asserted separately by header_hygiene_*.
2626

27+
#include <microhttpd.h>
2728
#include <sys/types.h> // ssize_t
2829
#include <unistd.h> // pipe, close
30+
2931
#include <cerrno>
3032
#include <cstdint>
3133
#include <cstring>
@@ -36,8 +38,6 @@
3638
#include <utility>
3739
#include <vector>
3840

39-
#include <microhttpd.h>
40-
4141
#include "./httpserver.hpp" // public umbrella → body_kind
4242
#include "httpserver/details/body.hpp" // private hierarchy
4343
#include "./littletest.hpp"
@@ -53,11 +53,13 @@ static_assert(std::is_same_v<std::underlying_type_t<httpserver::body_kind>,
5353
static_assert(static_cast<int>(httpserver::body_kind::empty) == 0,
5454
"body_kind::empty must be the zero-initialised value");
5555
// Reference each enumerator at compile time so a missing one breaks the build.
56-
static_assert(static_cast<int>(httpserver::body_kind::string) >= 0);
57-
static_assert(static_cast<int>(httpserver::body_kind::file) >= 0);
58-
static_assert(static_cast<int>(httpserver::body_kind::iovec) >= 0);
59-
static_assert(static_cast<int>(httpserver::body_kind::pipe) >= 0);
60-
static_assert(static_cast<int>(httpserver::body_kind::deferred) >= 0);
56+
// Comparing against `empty` (=0) avoids -Wtype-limits on uint8_t-backed enums
57+
// while still touching every name.
58+
static_assert(httpserver::body_kind::string != httpserver::body_kind::empty);
59+
static_assert(httpserver::body_kind::file != httpserver::body_kind::empty);
60+
static_assert(httpserver::body_kind::iovec != httpserver::body_kind::empty);
61+
static_assert(httpserver::body_kind::pipe != httpserver::body_kind::empty);
62+
static_assert(httpserver::body_kind::deferred != httpserver::body_kind::empty);
6163

6264
// -----------------------------------------------------------------------
6365
// Step 2 — abstract base contract.
@@ -248,7 +250,11 @@ LT_BEGIN_AUTO_TEST(body_suite, deferred_body_trampoline_invokes_stored_callable)
248250
[&](uint64_t pos, char* buf, std::size_t max) -> ssize_t {
249251
called = true;
250252
(void)pos;
251-
if (max >= 2) { buf[0] = 'h'; buf[1] = 'i'; return 2; }
253+
if (max >= 2) {
254+
buf[0] = 'h';
255+
buf[1] = 'i';
256+
return 2;
257+
}
252258
return 0;
253259
});
254260
char out[16] = {};

test/unit/header_hygiene_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363
// preprocessor-grep target `make check-hygiene` in the top-level
6464
// Makefile.am. Keep both lists in sync.
6565

66-
#include <httpserver.hpp>
67-
6866
#include <cstdio>
6967

68+
#include <httpserver.hpp>
69+
7070
int main() {
7171
int leaks = 0;
7272

test/unit/http_method_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
// layout / width pinning, bitwise composition, complement bounding,
2424
// to_string totality, and round-trip via set/contains.
2525

26-
#include <cstdint>
2726
#include <microhttpd.h>
27+
28+
#include <cstdint>
2829
#include <string_view>
2930
#include <type_traits>
3031

@@ -118,7 +119,7 @@ static_assert((~httpserver::http_method::get)
118119
.contains(httpserver::http_method::post));
119120

120121
// Compound assignment usable in constant context.
121-
static_assert([]{
122+
static_assert([] {
122123
httpserver::method_set s{};
123124
s |= httpserver::http_method::get;
124125
s |= httpserver::http_method::post;

test/unit/iovec_entry_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
// guarantee that downstream code does NOT see <sys/uio.h> via the umbrella
2525
// is asserted separately by `header_hygiene_iovec_test.cpp`.
2626

27-
#include <cstddef>
2827
#include <microhttpd.h>
2928
#include <sys/uio.h>
29+
30+
#include <cstddef>
3031
#include <type_traits>
3132

3233
#include "./httpserver.hpp"

0 commit comments

Comments
 (0)