Skip to content

Commit e118f88

Browse files
committed
Added line wraps and added/removed const where appropriate
1 parent 9643b15 commit e118f88

File tree

7 files changed

+21
-16
lines changed

7 files changed

+21
-16
lines changed

include/callstack.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* CallstackLibrary - Library creating human-readable call stacks.
33
*
4-
* Copyright (C) 2022 - 2024 mhahnFr
4+
* Copyright (C) 2022 - 2025 mhahnFr
55
*
66
* This file is part of the CallstackLibrary.
77
*
@@ -185,7 +185,7 @@ struct callstack_frame* callstack_getBinariesCached(struct callstack* self);
185185
* @param self The callstack object.
186186
* @return The number of frames in the given callstack.
187187
*/
188-
static inline size_t callstack_getFrameCount(struct callstack * self) {
188+
static inline size_t callstack_getFrameCount(const struct callstack* self) {
189189
return self->backtraceSize;
190190
}
191191

@@ -195,7 +195,7 @@ static inline size_t callstack_getFrameCount(struct callstack * self) {
195195
* @param self The callstack object.
196196
* @return The type of the callstack.
197197
*/
198-
static inline enum callstack_type callstack_getType(struct callstack * self) {
198+
static inline enum callstack_type callstack_getType(const struct callstack* self) {
199199
return self->translationStatus;
200200
}
201201

@@ -205,7 +205,7 @@ static inline enum callstack_type callstack_getType(struct callstack * self) {
205205
* @param self The callstack object.
206206
* @return Whether the callstack is already translated.
207207
*/
208-
static inline bool callstack_isTranslated(struct callstack * self) {
208+
static inline bool callstack_isTranslated(const struct callstack* self) {
209209
return self->translationStatus != NONE && self->translationStatus != FAILED;
210210
}
211211

include/callstack_frame.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ char * callstack_frame_getShortestName(const struct callstack_frame * self);
157157
* @return the shortest binary file name or the given fallback
158158
* @since v1.2
159159
*/
160-
static inline const char* callstack_frame_getShortestNameOr(const struct callstack_frame* self, const char* fallback) {
160+
static inline const char* callstack_frame_getShortestNameOr(const struct callstack_frame* self,
161+
const char* fallback) {
161162
const char* shortest = callstack_frame_getShortestName(self);
162163
return shortest == NULL ? fallback : shortest;
163164
}
@@ -181,7 +182,8 @@ char * callstack_frame_getShortestSourceFile(const struct callstack_frame * self
181182
* @return the shortest source file name or the given fallback
182183
* @since v1.2
183184
*/
184-
static inline const char* callstack_frame_getShortestSourceFileOr(const struct callstack_frame* self, const char* fallback) {
185+
static inline const char* callstack_frame_getShortestSourceFileOr(const struct callstack_frame* self,
186+
const char* fallback) {
185187
const char* shortest = callstack_frame_getShortestSourceFile(self);
186188
return shortest == NULL ? fallback : shortest;
187189
}
@@ -192,7 +194,7 @@ static inline const char* callstack_frame_getShortestSourceFileOr(const struct c
192194
* @param self the callstack frame to be destructed
193195
* @since v1.1
194196
*/
195-
static inline void callstack_frame_destroy(struct callstack_frame * self) {
197+
static inline void callstack_frame_destroy(const struct callstack_frame* self) {
196198
if (!self->reserved1) {
197199
free(self->binaryFile);
198200
free(self->binaryFileRelative);

src/functionInfo/functionInfo.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
* @param functionInfo the function info structure to be filled
3535
* @return whether the structure was filled, e. g. whether the function was found in the runtime image
3636
*/
37-
static inline bool functionInfo_getFrom(struct loadedLibInfo* info, const char* functionName, struct functionInfo* functionInfo) {
38-
return functionInfo->found = loadedLibInfo_prepare(info) && binaryFile_getFunctionInfo(info->associated, functionName, functionInfo);
37+
static inline bool functionInfo_getFrom(struct loadedLibInfo* info,
38+
const char* functionName,
39+
struct functionInfo* functionInfo) {
40+
return functionInfo->found = loadedLibInfo_prepare(info)
41+
&& binaryFile_getFunctionInfo(info->associated, functionName, functionInfo);
3942
}
4043

4144
struct functionInfo functionInfo_loadHint(const char* functionName, const char* libraryName) {

src/parser/file/dwarf/v4/parser.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ static inline bool dwarf4_parseLineProgramHeader(struct dwarf_parser* self, size
8686
* @param defaultDirectory the compilation directory
8787
* @return an allocated full path string of the given file or `NULL` if the allocation failed or the main source file was referred
8888
*/
89-
static inline char* dwarf4_stringFrom(const struct dwarf_fileNameEntry* file, const struct vector_string* directories, const char* defaultDirectory) {
89+
static inline char* dwarf4_stringFrom(const struct dwarf_fileNameEntry* file,
90+
const struct vector_string* directories,
91+
const char* defaultDirectory) {
9092
if (*file->name == '/') {
9193
return strdup(file->name);
9294
}

src/parser/file/dwarf/v5/parser.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
*/
2121

2222
#include "parser.h"
23+
2324
#include "definitions.h"
2425
#include "optional_vector_fileAttribute.h"
25-
2626
#include "../dwarf_parser.h"
2727
#include "../leb128.h"
2828
#include "../vector_pair_uint64.h"
29-
3029
#include "../../optional_uint64_t.h"
3130

3231
/**
@@ -154,7 +153,7 @@ static inline uint8_t* dwarf5_readMD5(void* buffer, size_t* counter) {
154153
* @param counter the reading index
155154
* @return the parsed file attributes or an empty optional if the parsing failed
156155
*/
157-
static inline optional_vector_fileAttribute_t dwarf5_parseFileAttributes(struct dwarf_parser* self, size_t* counter) {
156+
static inline optional_vector_fileAttribute_t dwarf5_parseFileAttributes(const struct dwarf_parser* self, size_t* counter) {
158157
const uint8_t entryFormatCount = *(uint8_t*) (self->debugLine.content + (*counter)++);
159158
vector_pair_uint64_t entryFormats = vector_initializer;
160159
vector_reserve(&entryFormats, entryFormatCount);

src/parser/file/macho/machoFile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ machoFile_handleSegment(struct segment_command_64, 64)
269269
* @param function the function / object file object pair
270270
* @param args the argument list
271271
*/
272-
static inline void machoFile_addFunction(struct pair_funcFile function, const va_list args) {
272+
static inline void machoFile_addFunction(struct pair_funcFile function, va_list args) {
273273
struct machoFile* self = va_arg(args, void*);
274274

275275
vector_push_back(&self->functions, function);

src/parser/file/macho/objectFile.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
* CallstackLibrary, see the file LICENSE. If not, see <https://www.gnu.org/licenses/>.
2020
*/
2121

22-
#include <stdarg.h>
2322
#include <stdio.h>
2423
#include <stdlib.h>
2524
#include <mach-o/loader.h>
@@ -293,7 +292,7 @@ static inline bool objectFile_handleSegment(struct objectFile* self,
293292
* @param f the function / object file pair
294293
* @param args the arguments - should contain as first argument the object file object ot add the pair to
295294
*/
296-
static inline void objectFile_addFunctionCallback(struct pair_funcFile f, const va_list args) {
295+
static inline void objectFile_addFunctionCallback(struct pair_funcFile f, va_list args) {
297296
struct objectFile* self = va_arg(args, void*);
298297

299298
vector_push_back(&self->ownFunctions, f.first);

0 commit comments

Comments
 (0)