From 3b1e7215e82a6d3e209976fb75d4c3a5d20ea00e Mon Sep 17 00:00:00 2001 From: Eric Betts Date: Wed, 24 Jul 2024 17:09:11 -0700 Subject: [PATCH] 0.104.0 format --- .clang-format | 129 +++++++++++++++++++++++++---------- assembly.h | 34 ++++----- ccid.h | 56 ++++++++------- protocol/picopass_poller_i.h | 2 +- protocol/picopass_protocol.h | 28 ++++---- protocol/rfal_picopass.h | 2 +- sam_api.c | 8 +-- seader_credential.h | 4 +- seader_worker.c | 4 +- seader_worker_i.h | 2 +- 10 files changed, 164 insertions(+), 105 deletions(-) diff --git a/.clang-format b/.clang-format index 4b76f7f..c420689 100644 --- a/.clang-format +++ b/.clang-format @@ -3,22 +3,55 @@ Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: AlwaysBreak AlignArrayOfStructures: None -AlignConsecutiveMacros: None -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: true + AcrossComments: true + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: true + AlignCompound: true + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false AlignEscapedNewlines: Left AlignOperands: Align -AlignTrailingComments: false +AlignTrailingComments: + Kind: Never + OverEmptyLines: 0 AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false -AllowShortEnumsOnASingleLine: true +AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: false AllowShortFunctionsOnASingleLine: None -AllowShortLambdasOnASingleLine: All AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLoopsOnASingleLine: true +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false @@ -27,17 +60,18 @@ AttributeMacros: - __capability BinPackArguments: false BinPackParameters: false +BitFieldColonSpacing: Both BraceWrapping: AfterCaseLabel: false AfterClass: false AfterControlStatement: Never AfterEnum: false + AfterExternBlock: false AfterFunction: false AfterNamespace: false AfterObjCDeclaration: false AfterStruct: false AfterUnion: false - AfterExternBlock: false BeforeCatch: false BeforeElse: false BeforeLambdaBody: false @@ -46,38 +80,35 @@ BraceWrapping: SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: true -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: BeforeComma +BreakInheritanceList: BeforeColon BreakStringLiterals: false ColumnLimit: 99 CommentPragmas: '^ IWYU pragma:' -QualifierAlignment: Leave CompactNamespaces: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true -DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false -PackConstructorInitializers: BinPack -BasedOnStyle: '' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -AllowAllConstructorInitializersOnNextLine: true FixNamespaceComments: false ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH + - M_EACH IfMacros: - KJ_IF_MAYBE IncludeBlocks: Preserve @@ -97,19 +128,30 @@ IncludeCategories: IncludeIsMainRegex: '(Test)?$' IncludeIsMainSourceRegex: '' IndentAccessModifiers: false -IndentCaseLabels: false IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: AfterExternBlock IndentGotoLabels: true IndentPPDirectives: None -IndentExternBlock: AfterExternBlock -IndentRequires: false +IndentRequiresClause: false IndentWidth: 4 IndentWrappedFunctionNames: true +InsertBraces: false +InsertNewlineAtEOF: true InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false +KeepEmptyLinesAtEOF: false LambdaBodyIndentation: Signature +LineEnding: DeriveLF MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 @@ -119,34 +161,44 @@ ObjCBlockIndentWidth: 4 ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: BinPack PenaltyBreakAssignment: 10 PenaltyBreakBeforeFirstCallParameter: 30 PenaltyBreakComment: 10 PenaltyBreakFirstLessLess: 0 PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 PenaltyBreakString: 10 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 100 -PenaltyReturnTypeOnItsOwnLine: 60 PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left PPIndentWidth: -1 +QualifierAlignment: Leave ReferenceAlignment: Pointer ReflowComments: false RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: true +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope SeparateDefinitionBlocks: Leave ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false SortIncludes: Never SortJavaStaticImport: Before -SortUsingDeclarations: false +SortUsingDeclarations: Never SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false SpaceBeforeParens: Never SpaceBeforeParensOptions: AfterControlStatements: false @@ -155,32 +207,35 @@ SpaceBeforeParensOptions: AfterFunctionDeclarationName: false AfterIfMacros: false AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false BeforeNonEmptyParentheses: false -SpaceAroundPointerQualifiers: Default SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: Never -SpacesInConditionalStatement: false SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false SpacesInLineCommentPrefix: Minimum: 1 Maximum: -1 -SpacesInParentheses: false +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -BitFieldColonSpacing: Both -Standard: c++03 +Standard: c++20 StatementAttributeLikeMacros: - Q_EMIT StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION TabWidth: 4 -UseCRLF: false UseTab: Never +VerilogBreakBetweenInstancePorts: true WhitespaceSensitiveMacros: - STRINGIZE - PP_STRINGIZE diff --git a/assembly.h b/assembly.h index a659ef7..13c0d1d 100644 --- a/assembly.h +++ b/assembly.h @@ -27,8 +27,8 @@ #endif #if defined(__APPLE__) -#define HIDDEN(name) .private_extern name -#define LOCAL_LABEL(name) L_##name +#define HIDDEN(name) .private_extern name +#define LOCAL_LABEL(name) L_##name // tell linker it can break up file at label boundaries #define FILE_LEVEL_DIRECTIVE .subsections_via_symbols #define SYMBOL_IS_FUNC(name) @@ -38,7 +38,7 @@ #elif defined(__ELF__) -#define HIDDEN(name) .hidden name +#define HIDDEN(name) .hidden name #define LOCAL_LABEL(name) .L_##name #define FILE_LEVEL_DIRECTIVE #if defined(__arm__) || defined(__aarch64__) @@ -60,7 +60,7 @@ #define LOCAL_LABEL(name) .L##name #define FILE_LEVEL_DIRECTIVE #define SYMBOL_IS_FUNC(name) .def name SEPARATOR.scl 2 SEPARATOR.type 32 SEPARATOR.endef -#define CONST_SECTION .section.rdata, "rd" +#define CONST_SECTION .section.rdata, "rd" #define NO_EXEC_STACK_DIRECTIVE @@ -73,7 +73,7 @@ #endif // BTI and PAC gnu property note -#define NT_GNU_PROPERTY_TYPE_0 5 +#define NT_GNU_PROPERTY_TYPE_0 5 #define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000 #define GNU_PROPERTY_AARCH64_FEATURE_1_BTI 1 #define GNU_PROPERTY_AARCH64_FEATURE_1_PAC 2 @@ -112,7 +112,7 @@ #if defined(__clang__) || defined(__GCC_HAVE_DWARF2_CFI_ASM) #define CFI_START .cfi_startproc -#define CFI_END .cfi_endproc +#define CFI_END .cfi_endproc #else #define CFI_START #define CFI_END @@ -124,11 +124,11 @@ // - for '-mthumb -march=armv6' compiler defines '__thumb__' // - for '-mthumb -march=armv7' compiler defines '__thumb__' and '__thumb2__' #if defined(__thumb2__) || defined(__thumb__) -#define DEFINE_CODE_STATE .thumb SEPARATOR +#define DEFINE_CODE_STATE .thumb SEPARATOR #define DECLARE_FUNC_ENCODING .thumb_func SEPARATOR #if defined(__thumb2__) #define USE_THUMB_2 -#define IT(cond) it cond +#define IT(cond) it cond #define ITT(cond) itt cond #define ITE(cond) ite cond #else @@ -158,10 +158,10 @@ #endif #ifdef ARM_HAS_BX -#define JMP(r) bx r +#define JMP(r) bx r #define JMPc(r, c) bx##c r #else -#define JMP(r) mov pc, r +#define JMP(r) mov pc, r #define JMPc(r, c) mov##c pc, r #endif @@ -187,18 +187,18 @@ #define DEFINE_CODE_STATE #endif -#define GLUE2_(a, b) a##b -#define GLUE(a, b) GLUE2_(a, b) -#define GLUE2(a, b) GLUE2_(a, b) -#define GLUE3_(a, b, c) a##b##c -#define GLUE3(a, b, c) GLUE3_(a, b, c) +#define GLUE2_(a, b) a##b +#define GLUE(a, b) GLUE2_(a, b) +#define GLUE2(a, b) GLUE2_(a, b) +#define GLUE3_(a, b, c) a##b##c +#define GLUE3(a, b, c) GLUE3_(a, b, c) #define GLUE4_(a, b, c, d) a##b##c##d -#define GLUE4(a, b, c, d) GLUE4_(a, b, c, d) +#define GLUE4(a, b, c, d) GLUE4_(a, b, c, d) #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) #ifdef VISIBILITY_HIDDEN -#define DECLARE_SYMBOL_VISIBILITY(name) HIDDEN(SYMBOL_NAME(name)) SEPARATOR +#define DECLARE_SYMBOL_VISIBILITY(name) HIDDEN(SYMBOL_NAME(name)) SEPARATOR #define DECLARE_SYMBOL_VISIBILITY_UNMANGLED(name) HIDDEN(name) SEPARATOR #else #define DECLARE_SYMBOL_VISIBILITY(name) diff --git a/ccid.h b/ccid.h index 11b8844..28a1e80 100644 --- a/ccid.h +++ b/ccid.h @@ -11,7 +11,7 @@ #define SYNC (0x03) #define CTRL (0x06) -#define NAK (0x15) +#define NAK (0x15) #define BMICCSTATUS_MASK 0x03 /* @@ -23,48 +23,52 @@ // TODO: rename/renumber #define SLOT_0_MASK 0x03 -#define CARD_OUT_1 0x02 -#define CARD_IN_1 0x03 +#define CARD_OUT_1 0x02 +#define CARD_IN_1 0x03 #define SLOT_1_MASK 0x0C -#define CARD_IN_2 0x04 -#define CARD_OUT_2 0x0C +#define CARD_IN_2 0x04 +#define CARD_OUT_2 0x0C /* * * BULK_OUT messages from PC to Reader * * Defined in CCID Rev 1.1 6.1 (page 26) * */ -#define CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn 0x62 -#define CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOff 0x63 -#define CCID_MESSAGE_TYPE_PC_to_RDR_GetSlotStatus 0x65 -#define CCID_MESSAGE_TYPE_PC_to_RDR_XfrBlock 0x6f -#define CCID_MESSAGE_TYPE_PC_to_RDR_GetParameters 0x6c -#define CCID_MESSAGE_TYPE_PC_to_RDR_ResetParameters 0x6d -#define CCID_MESSAGE_TYPE_PC_to_RDR_SetParameters 0x61 -#define CCID_MESSAGE_TYPE_PC_to_RDR_Escape 0x6b -#define CCID_MESSAGE_TYPE_PC_to_RDR_IccClock 0x6e -#define CCID_MESSAGE_TYPE_PC_to_RDR_T0APDU 0x6a -#define CCID_MESSAGE_TYPE_PC_to_RDR_Secure 0x69 -#define CCID_MESSAGE_TYPE_PC_to_RDR_Mechanical 0x71 -#define CCID_MESSAGE_TYPE_PC_to_RDR_Abort 0x72 +#define CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn 0x62 +#define CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOff 0x63 +#define CCID_MESSAGE_TYPE_PC_to_RDR_GetSlotStatus 0x65 +#define CCID_MESSAGE_TYPE_PC_to_RDR_XfrBlock 0x6f +#define CCID_MESSAGE_TYPE_PC_to_RDR_GetParameters 0x6c +#define CCID_MESSAGE_TYPE_PC_to_RDR_ResetParameters 0x6d +#define CCID_MESSAGE_TYPE_PC_to_RDR_SetParameters 0x61 +#define CCID_MESSAGE_TYPE_PC_to_RDR_Escape 0x6b +#define CCID_MESSAGE_TYPE_PC_to_RDR_IccClock 0x6e +#define CCID_MESSAGE_TYPE_PC_to_RDR_T0APDU 0x6a +#define CCID_MESSAGE_TYPE_PC_to_RDR_Secure 0x69 +#define CCID_MESSAGE_TYPE_PC_to_RDR_Mechanical 0x71 +#define CCID_MESSAGE_TYPE_PC_to_RDR_Abort 0x72 #define CCID_MESSAGE_TYPE_PC_to_RDR_SetDataRateAndClockFrequency 0x73 /* * * BULK_IN messages from Reader to PC * * Defined in CCID Rev 1.1 6.2 (page 48) * */ -#define CCID_MESSAGE_TYPE_RDR_to_PC_DataBlock 0x80 -#define CCID_MESSAGE_TYPE_RDR_to_PC_SlotStatus 0x81 -#define CCID_MESSAGE_TYPE_RDR_to_PC_Parameters 0x82 -#define CCID_MESSAGE_TYPE_RDR_to_PC_Escape 0x83 -#define CCID_MESSAGE_TYPE_RDR_to_PC_DataRateAndClockFrequency 0x84 +#define CCID_MESSAGE_TYPE_RDR_to_PC_DataBlock 0x80 +#define CCID_MESSAGE_TYPE_RDR_to_PC_SlotStatus 0x81 +#define CCID_MESSAGE_TYPE_RDR_to_PC_Parameters 0x82 +#define CCID_MESSAGE_TYPE_RDR_to_PC_Escape 0x83 +#define CCID_MESSAGE_TYPE_RDR_to_PC_DataRateAndClockFrequency 0x84 /* * * INTERRUPT_IN messages from Reader to PC * * Defined in CCID Rev 1.1 6.3 (page 56) * */ -#define CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange 0x50 -#define CCID_MESSAGE_TYPE_RDR_to_PC_HardwareError 0x51 +#define CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange 0x50 +#define CCID_MESSAGE_TYPE_RDR_to_PC_HardwareError 0x51 /* Status codes that go in bStatus (see 6.2.6) */ -enum { ICC_STATUS_PRESENT_ACTIVE = 0, ICC_STATUS_PRESENT_INACTIVE, ICC_STATUS_NOT_PRESENT }; +enum { + ICC_STATUS_PRESENT_ACTIVE = 0, + ICC_STATUS_PRESENT_INACTIVE, + ICC_STATUS_NOT_PRESENT +}; enum { COMMAND_STATUS_NO_ERROR = 0, COMMAND_STATUS_FAILED, diff --git a/protocol/picopass_poller_i.h b/protocol/picopass_poller_i.h index 5ae8818..3f397db 100644 --- a/protocol/picopass_poller_i.h +++ b/protocol/picopass_poller_i.h @@ -7,7 +7,7 @@ #include #define PICOPASS_POLLER_BUFFER_SIZE (255) -#define PICOPASS_CRC_SIZE (2) +#define PICOPASS_CRC_SIZE (2) typedef enum { PicopassPollerSessionStateIdle, diff --git a/protocol/picopass_protocol.h b/protocol/picopass_protocol.h index 73c549c..145ae0e 100644 --- a/protocol/picopass_protocol.h +++ b/protocol/picopass_protocol.h @@ -1,22 +1,22 @@ #pragma once -#define PICOPASS_BLOCK_LEN 8 -#define PICOPASS_MAX_APP_LIMIT 32 -#define PICOPASS_UID_LEN 8 +#define PICOPASS_BLOCK_LEN 8 +#define PICOPASS_MAX_APP_LIMIT 32 +#define PICOPASS_UID_LEN 8 #define PICOPASS_READ_CHECK_RESP_LEN 8 -#define PICOPASS_CHECK_RESP_LEN 4 -#define PICOPASS_MAC_LEN 4 -#define PICOPASS_KEY_LEN 8 +#define PICOPASS_CHECK_RESP_LEN 4 +#define PICOPASS_MAC_LEN 4 +#define PICOPASS_KEY_LEN 8 -#define CSN_INDEX 0 -#define CFG_INDEX 1 -#define EPURSE_INDEX 2 -#define KD_INDEX 3 -#define KC_INDEX 4 -#define AIA_INDEX 5 +#define CSN_INDEX 0 +#define CFG_INDEX 1 +#define EPURSE_INDEX 2 +#define KD_INDEX 3 +#define KC_INDEX 4 +#define AIA_INDEX 5 #define PACS_CFG_INDEX 6 -#define PACS_INDEX 7 -#define SR_SIO_INDEX 10 +#define PACS_INDEX 7 +#define SR_SIO_INDEX 10 #define PICOPASS_FDT_LISTEN_FC (1000) diff --git a/protocol/rfal_picopass.h b/protocol/rfal_picopass.h index 9dd0cbf..22c103b 100644 --- a/protocol/rfal_picopass.h +++ b/protocol/rfal_picopass.h @@ -3,7 +3,7 @@ #include #define RFAL_PICOPASS_UID_LEN 8 -#define PICOPASS_BLOCK_LEN 8 +#define PICOPASS_BLOCK_LEN 8 enum { // PicoPass command bytes: diff --git a/sam_api.c b/sam_api.c index f4de8a0..fbc100d 100644 --- a/sam_api.c +++ b/sam_api.c @@ -6,11 +6,11 @@ #define TAG "SAMAPI" -#define APDU_HEADER_LEN 5 -#define ASN1_PREFIX 6 -#define ASN1_DEBUG true +#define APDU_HEADER_LEN 5 +#define ASN1_PREFIX 6 +#define ASN1_DEBUG true #define SEADER_ICLASS_SR_SIO_BASE_BLOCK 10 -#define SEADER_SERIAL_FILE_NAME "sam_serial" +#define SEADER_SERIAL_FILE_NAME "sam_serial" const uint8_t picopass_iclass_key[] = {0xaf, 0xa7, 0x85, 0xa7, 0xda, 0xb3, 0x33, 0x78}; diff --git a/seader_credential.h b/seader_credential.h index 3ea98b2..b72e3ba 100644 --- a/seader_credential.h +++ b/seader_credential.h @@ -7,9 +7,9 @@ #include "protocol/picopass_protocol.h" #define SEADER_CRED_NAME_MAX_LEN 22 -#define SEADER_APP_EXTENSION ".credential" +#define SEADER_APP_EXTENSION ".credential" #define SEADER_APP_MFC_EXTENSION ".nfc" -#define SEADER_APP_MFC_FOLDER ANY_PATH("nfc") +#define SEADER_APP_MFC_FOLDER ANY_PATH("nfc") typedef void (*SeaderLoadingCallback)(void* context, bool state); diff --git a/seader_worker.c b/seader_worker.c index 8ec74de..28ebbde 100644 --- a/seader_worker.c +++ b/seader_worker.c @@ -6,8 +6,8 @@ #define TAG "SeaderWorker" #define APDU_HEADER_LEN 5 -#define ASN1_PREFIX 6 -#define ASN1_DEBUG true +#define ASN1_PREFIX 6 +#define ASN1_DEBUG true #define RFAL_PICOPASS_TXRX_FLAGS \ (FURI_HAL_NFC_LL_TXRX_FLAGS_CRC_TX_MANUAL | FURI_HAL_NFC_LL_TXRX_FLAGS_AGC_ON | \ diff --git a/seader_worker_i.h b/seader_worker_i.h index 2ac6422..65c9676 100644 --- a/seader_worker_i.h +++ b/seader_worker_i.h @@ -13,7 +13,7 @@ #include #include -#define SEADER_POLLER_MAX_FWT (200000U) +#define SEADER_POLLER_MAX_FWT (200000U) #define SEADER_POLLER_MAX_BUFFER_SIZE (255U) struct SeaderWorker {