From 88f60115830ed51e3585b855963f25de2acccf57 Mon Sep 17 00:00:00 2001 From: fpagliughi Date: Wed, 11 Feb 2026 15:58:38 -0500 Subject: [PATCH 1/2] Added a .clang-format file and bash script to run it over the directory tree. --- .clang-format | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ fmt.sh | 7 +++++ 2 files changed, 86 insertions(+) create mode 100644 .clang-format create mode 100755 fmt.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..1ebf1c2a --- /dev/null +++ b/.clang-format @@ -0,0 +1,79 @@ +--- +Language: C + +# Indentation: tabs, one tab per indent level +# The Emacs footer in source files specifies indent-tabs-mode: t +UseTab: ForIndentation +TabWidth: 4 +IndentWidth: 4 +ContinuationIndentWidth: 8 +IndentCaseLabels: true +IndentCaseBlocks: false +IndentGotoLabels: false +IndentPPDirectives: None +IndentWrappedFunctionNames: false + +# Braces: Allman style - opening brace on its own line for everything +BreakBeforeBraces: Allman + +# Alignment +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true + +# Pointer style: mixed in codebase (char* ptr and char *ptr both appear), +# derive per file with Left as default +PointerAlignment: Left +DerivePointerAlignment: true + +# Spaces +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpacesBeforeTrailingComments: 1 + +# Line breaking +ColumnLimit: 120 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +BinPackArguments: true +BinPackParameters: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakStringLiterals: true + +# Includes: preserve existing order, do not sort +SortIncludes: Never +IncludeBlocks: Preserve + +# Blank lines +MaxEmptyLinesToKeep: 2 + +# Comments: do not reflow to preserve manual formatting +ReflowComments: false + +# Penalties for line breaking decisions +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 diff --git a/fmt.sh b/fmt.sh new file mode 100755 index 00000000..6796e42e --- /dev/null +++ b/fmt.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# +# Runs clang format over the whole project tree, excluding the 'build/' directory. +# + +find . -type d \( -path './build' \) -prune -iname '*.h' -o -iname '*.c' | xargs clang-format -i + From 4ab5e089bb31b803f68e5d77df4e67579c1c517f Mon Sep 17 00:00:00 2001 From: fpagliughi Date: Fri, 13 Feb 2026 00:59:48 -0600 Subject: [PATCH 2/2] Fixed warning in Window build for TCP_NODELAY --- src/Socket.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Socket.c b/src/Socket.c index d2ebfdab..88ad80e6 100644 --- a/src/Socket.c +++ b/src/Socket.c @@ -1457,17 +1457,18 @@ int Socket_new(const char* addr, size_t addr_len, int port, SOCKET* sock) else { #if defined(NOSIGPIPE) - int opt = 1; + { + int opt = 1; - if (setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0) - Log(LOG_ERROR, -1, "Could not set SO_NOSIGPIPE for socket %d", *sock); + if (setsockopt(*sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&opt, sizeof(opt)) != 0) + Log(LOG_ERROR, -1, "Could not set SO_NOSIGPIPE for socket %d", *sock); + } #endif #if !defined(NO_TCP_NODELAY) { int opt = 1; - socklen_t opt_size = sizeof(opt); - - if (setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)) != 0) + + if (setsockopt(*sock, IPPROTO_TCP, TCP_NODELAY, (void*)&opt, sizeof(opt)) != 0) Log(LOG_ERROR, -1, "Could not set TCP_NODELAY for socket %d", *sock); } #endif