mattgodbolt / seasocks

Simple, small, C++ embeddable webserver with WebSockets support
BSD 2-Clause "Simplified" License
724 stars 120 forks source link

Clang 13 and 14 CI builds #165

Closed offa closed 2 years ago

offa commented 2 years ago

Adds builds for latest Clang versions.

Both issue an error due to possible UB though:

/home/runner/work/seasocks/seasocks/src/main/c/md5/md5.cpp:190:25: error: performing pointer subtraction with a null pointer may have undefined behavior [-Werror,-Wnull-pointer-subtraction]
            if (!((data - (const md5_byte_t*) 0) & 3)) {
                        ^ ~~~~~~~~~~~~~~~~~~~~~
1 error generated.
codecov[bot] commented 2 years ago

Codecov Report

Merging #165 (8854043) into master (91b35eb) will increase coverage by 0.97%. The diff coverage is n/a.

:exclamation: Current head 8854043 differs from pull request most recent head bd17986. Consider uploading reports for the commit bd17986 to get more accurate results

@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage   35.88%   36.85%   +0.97%     
==========================================
  Files          53       49       -4     
  Lines        2302     2233      -69     
==========================================
- Hits          826      823       -3     
+ Misses       1476     1410      -66     
Impacted Files Coverage Δ
src/main/c/md5/md5.cpp 0.00% <0.00%> (ø)
src/main/c/PageRequest.cpp 0.00% <0.00%> (ø)
src/main/c/seasocks/SimpleResponse.h 0.00% <0.00%> (ø)
src/main/c/seasocks/ZlibContext.h
src/main/c/seasocks/StrCompare.h
src/main/c/seasocks/ZlibContextDisabled.cpp
src/main/c/seasocks/util/RootPageHandler.h
src/main/c/Connection.cpp 20.39% <0.00%> (+0.52%) :arrow_up:
src/main/c/Server.cpp 27.01% <0.00%> (+0.94%) :arrow_up:
src/main/c/seasocks/ResponseBuilder.cpp 13.33% <0.00%> (+1.21%) :arrow_up:
... and 7 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

offa commented 2 years ago

I have updated to latest release 2.13.9, since there's an issue related to MINSIGSTKSZ / constexpr.

rayburgemeestre commented 2 years ago

Hi guys,

I also ran into this issue today, I took a fix from: https://github.com/Haivision/srt/pull/2392 and at least that makes it compile again. I don't know if you guys would like to apply the same fix, this is the diff

--- a/src/main/c/md5/md5.cpp
+++ b/src/main/c/md5/md5.cpp
@@ -79,6 +79,7 @@
 #include "md5/md5.h"

 #include <cstring>
+#include <cstdint>

 #undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
 #ifdef ARCH_IS_BIG_ENDIAN
@@ -187,7 +188,7 @@ md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/) {
          * On little-endian machines, we can process properly aligned
          * data without copying it.
          */
-            if (!((data - (const md5_byte_t*) 0) & 3)) {
+            if (!(uintptr_t(data) & 3)) {
                 /* data are properly aligned */
                 X = (const md5_word_t*) data;
             } else {
offa commented 2 years ago

Can you file a PR for this?

rayburgemeestre commented 2 years ago

Definitely, will do it later tonight!

offa commented 2 years ago

Thanks @rayburgemeestre, this PR is green now! :+1: