Skip to content

Commit

Permalink
Treat compiler warning as error
Browse files Browse the repository at this point in the history
  • Loading branch information
beef9999 committed Jan 16, 2024
1 parent bd08579 commit 7bfdc05
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ endif ()
ProcessorCount(NumCPU)

# Compiler options
add_compile_options(-Wall) # -Werror is not enable yet
add_compile_options(-Wall -Werror)

set(CMAKE_CXX_STANDARD ${PHOTON_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_definitions(-w)

add_executable(simple-example simple/simple.cpp)
target_link_libraries(simple-example PRIVATE photon_static)

Expand Down
2 changes: 1 addition & 1 deletion net/basic_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ ssize_t ISocketStream::recv_at_least_mutable(struct iovec *iov, int iovcnt,
if (ret == 0) break; // EOF
if ((n += ret) >= least) break;
auto r = v.extract_front(ret);
assert(r == ret); (void)r;
assert((ssize_t) r == ret); (void)r;
} while (v.iovcnt && v.iov->iov_len);
return n;
}
Expand Down
3 changes: 3 additions & 0 deletions net/http/headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ HeadersBase::KV* HeadersBase::kv_add_sort(KV kv) {
if ((char*)(begin - 1) <= m_buf + m_buf_size)
LOG_ERROR_RETURN(ENOBUFS, nullptr, "no buffer");
auto it = std::lower_bound(begin, kv_end(), kv, HA(this));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
memmove(begin - 1, begin, sizeof(KV) * (it - begin));
#pragma GCC diagnostic pop
m_kv_size++;
*(it - 1) = kv;
return it - 1;
Expand Down
2 changes: 1 addition & 1 deletion net/http/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void URL::fix_target() {
if (m_target.size() == 0 || t.front() != '/') {
m_tmp_target = (char*)malloc(m_target.size() + 1);
m_tmp_target[0] = '/';
strncpy(m_tmp_target+1, t.data(), t.size());
memcpy(m_tmp_target+1, t.data(), t.size());
m_target = rstring_view16(0, m_target.size()+1);
m_path = rstring_view16(0, m_path.size()+1);
}
Expand Down
3 changes: 3 additions & 0 deletions net/security-context/tls-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class TLSContextImpl : public TLSContext {
case TLSVersion::SSL23:
method = SSLv23_method();
break;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
case TLSVersion::TLS11:
method = TLSv1_1_method();
break;
Expand All @@ -109,6 +111,7 @@ class TLSContextImpl : public TLSContext {
break;
default:
method = TLSv1_2_method();
#pragma GCC diagnostic pop
}
ctx = SSL_CTX_new(method);
if (ctx == nullptr) {
Expand Down
8 changes: 4 additions & 4 deletions thread/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,15 +928,15 @@ R"(
size_t randomizer = (rand() % 32) * (1024 + 8);
stack_size = align_up(randomizer + stack_size + sizeof(thread), PAGE_SIZE);
char* ptr = (char*)photon_thread_alloc(stack_size);
auto p = ptr + stack_size - sizeof(thread) - randomizer;
(uint64_t&)p &= ~63;
auto th = new (p) thread;
uint64_t p = (uint64_t) ptr + stack_size - sizeof(thread) - randomizer;
p = align_down(p, 64);
auto th = new((char*) p) thread;
th->buf = ptr;
th->stackful_alloc_top = ptr;
th->start = start;
th->stack_size = stack_size;
th->arg = arg;
auto sp = align_down((uint64_t)p - reserved_space, 64);
auto sp = align_down(p - reserved_space, 64);
th->stack.init((void*)sp, &_photon_thread_stub, th);
AtomicRunQ arq(rq);
th->vcpu = arq.vcpu;
Expand Down

0 comments on commit 7bfdc05

Please sign in to comment.