Skip to content

Commit

Permalink
This is reformatting with clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Reformat github bot committed Jun 28, 2024
1 parent a3d61b5 commit 0b06069
Show file tree
Hide file tree
Showing 218 changed files with 8,322 additions and 12,089 deletions.
45 changes: 15 additions & 30 deletions Sources/KSCrashBootTimeMonitor/KSCrashMonitor_BootTime.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#import "KSCrashMonitor_BootTime.h"

#import "KSCrashMonitorContext.h"
#import "KSSysCtl.h"
#import "KSDate.h"
#import "KSSysCtl.h"

#import <sys/types.h>
#import <Foundation/Foundation.h>
#import <sys/types.h>

static volatile bool g_isEnabled = false;

Expand All @@ -47,58 +47,43 @@ void kscm_bootTime_resetState(void)
*
* @return The result of the sysctl call.
*/
static const char* dateSysctl(const char* name)
static const char *dateSysctl(const char *name)
{
struct timeval value = kssysctl_timevalForName(name);
char* buffer = malloc(21);
char *buffer = malloc(21);
ksdate_utcStringFromTimestamp(value.tv_sec, buffer);
return buffer;
}

#pragma mark - API -

static const char* monitorId(void)
{
return "BootTime";
}
static const char *monitorId(void) { return "BootTime"; }

static void setEnabled(bool isEnabled)
{
if(isEnabled != g_isEnabled)
{
if (isEnabled != g_isEnabled) {
g_isEnabled = isEnabled;
}
}

static bool isEnabled(void)
{
return g_isEnabled;
}
static bool isEnabled(void) { return g_isEnabled; }

static void addContextualInfoToEvent(KSCrash_MonitorContext* eventContext)
static void addContextualInfoToEvent(KSCrash_MonitorContext *eventContext)
{
if(g_isEnabled)
{
if (g_isEnabled) {
eventContext->System.bootTime = dateSysctl("kern.boottime");
}
}

KSCrashMonitorAPI* kscm_boottime_getAPI(void)
KSCrashMonitorAPI *kscm_boottime_getAPI(void)
{
static KSCrashMonitorAPI api =
{
.monitorId = monitorId,
.setEnabled = setEnabled,
.isEnabled = isEnabled,
.addContextualInfoToEvent = addContextualInfoToEvent
};
static KSCrashMonitorAPI api = { .monitorId = monitorId,
.setEnabled = setEnabled,
.isEnabled = isEnabled,
.addContextualInfoToEvent = addContextualInfoToEvent };
return &api;
}

#pragma mark - Injection -

__attribute__((constructor))
static void kscm_boottime_register(void)
{
kscm_addMonitor(kscm_boottime_getAPI());
}
__attribute__((constructor)) static void kscm_boottime_register(void) { kscm_addMonitor(kscm_boottime_getAPI()); }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// KSCrashMonitor_BootTime.h
//
//
// Created by Gleb Linnik on 04.06.2024.
//
// Copyright (c) 2012 Karl Stenerud. All rights reserved.
Expand All @@ -24,7 +24,6 @@
// THE SOFTWARE.
//


#ifndef KSCrashMonitor_BootTime_h
#define KSCrashMonitor_BootTime_h

Expand All @@ -36,7 +35,7 @@ extern "C" {

/** Access the Monitor API.
*/
KSCrashMonitorAPI* kscm_boottime_getAPI(void);
KSCrashMonitorAPI *kscm_boottime_getAPI(void);

#ifdef __cplusplus
}
Expand Down
43 changes: 20 additions & 23 deletions Sources/KSCrashCore/NSError+SimpleConstructor.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,51 @@

#import "NSError+SimpleConstructor.h"


@implementation NSError (SimpleConstructor)

+ (NSError*) errorWithDomain:(NSString*) domain code:(NSInteger) code description:(NSString*) fmt, ...
+ (NSError *)errorWithDomain:(NSString *)domain code:(NSInteger)code description:(NSString *)fmt, ...
{
va_list args;
va_start(args, fmt);
NSString* desc = [[NSString alloc] initWithFormat:fmt arguments:args];

NSString *desc = [[NSString alloc] initWithFormat:fmt arguments:args];
va_end(args);

return [NSError errorWithDomain:domain
code:code
userInfo:[NSDictionary dictionaryWithObject:desc
forKey:NSLocalizedDescriptionKey]];
userInfo:[NSDictionary dictionaryWithObject:desc forKey:NSLocalizedDescriptionKey]];
}

+ (BOOL) fillError:(NSError* __autoreleasing *) error
withDomain:(NSString*) domain
code:(NSInteger) code
description:(NSString*) fmt, ...
+ (BOOL)fillError:(NSError *__autoreleasing *)error
withDomain:(NSString *)domain
code:(NSInteger)code
description:(NSString *)fmt, ...
{
if(error != nil)
{
if (error != nil) {
va_list args;
va_start(args, fmt);
NSString* desc = [[NSString alloc] initWithFormat:fmt arguments:args];

NSString *desc = [[NSString alloc] initWithFormat:fmt arguments:args];
va_end(args);

*error = [NSError errorWithDomain:domain
code:code
userInfo:[NSDictionary dictionaryWithObject:desc
forKey:NSLocalizedDescriptionKey]];
userInfo:[NSDictionary dictionaryWithObject:desc forKey:NSLocalizedDescriptionKey]];
}
return NO;
}

+ (BOOL) clearError:(NSError* __autoreleasing *) error
+ (BOOL)clearError:(NSError *__autoreleasing *)error
{
if(error != nil)
{
if (error != nil) {
*error = nil;
}
return NO;
}

@end

@interface NSError_SimpleConstructor_AOG8G : NSObject @end @implementation NSError_SimpleConstructor_AOG8G @end

@interface NSError_SimpleConstructor_AOG8G : NSObject
@end
@implementation NSError_SimpleConstructor_AOG8G
@end
6 changes: 3 additions & 3 deletions Sources/KSCrashCore/include/KSSystemCapabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// THE SOFTWARE.
//


#ifndef HDR_KSSystemCapabilities_h
#define HDR_KSSystemCapabilities_h

Expand All @@ -44,7 +43,8 @@
#define KSCRASH_HOST_IOS (KSCRASH_HOST_APPLE && TARGET_OS_IOS)
#define KSCRASH_HOST_TV (KSCRASH_HOST_APPLE && TARGET_OS_TV)
#define KSCRASH_HOST_WATCH (KSCRASH_HOST_APPLE && TARGET_OS_WATCH)
#define KSCRASH_HOST_MAC (KSCRASH_HOST_APPLE && TARGET_OS_MAC && !(TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH || KSCRASH_HOST_VISION))
#define KSCRASH_HOST_MAC \
(KSCRASH_HOST_APPLE && TARGET_OS_MAC && !(TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH || KSCRASH_HOST_VISION))

#if KSCRASH_HOST_APPLE
#define KSCRASH_CAN_GET_MAC_ADDRESS 1
Expand Down Expand Up @@ -151,4 +151,4 @@
#define KSCRASH_HAS_REACHABILITY 0
#endif

#endif // HDR_KSSystemCapabilities_h
#endif // HDR_KSSystemCapabilities_h
11 changes: 3 additions & 8 deletions Sources/KSCrashCore/include/NSError+SimpleConstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
* @param fmt Description of the error (gets placed into the user data with the key
* NSLocalizedDescriptionKey).
*/
+ (NSError*) errorWithDomain:(NSString*) domain
code:(NSInteger) code
description:(NSString*) fmt, ...;
+ (NSError *)errorWithDomain:(NSString *)domain code:(NSInteger)code description:(NSString *)fmt, ...;

/** Fill an error pointer with an NSError object if it's not nil.
*
Expand All @@ -53,17 +51,14 @@
* NSLocalizedDescriptionKey).
* @return NO (to keep the analyzer happy).
*/
+ (BOOL) fillError:(NSError**) error
withDomain:(NSString*) domain
code:(NSInteger) code
description:(NSString*) fmt, ...;
+ (BOOL)fillError:(NSError **)error withDomain:(NSString *)domain code:(NSInteger)code description:(NSString *)fmt, ...;

/** Clear a pointer-to-error to nil of its pointer is not nil.
*
* @param error Error pointer to fill (ignored if nil).
* @return NO (to keep the analyzer happy).
*/
+ (BOOL) clearError:(NSError**) error;
+ (BOOL)clearError:(NSError **)error;

@end

Expand Down
45 changes: 14 additions & 31 deletions Sources/KSCrashDiscSpaceMonitor/KSCrashMonitor_DiscSpace.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// KSCrashMonitor_DiscSpace.c
//
//
// Created by Gleb Linnik on 04.06.2024.
//
// Copyright (c) 2012 Karl Stenerud. All rights reserved.
Expand Down Expand Up @@ -40,57 +40,40 @@ void kscm_discSpace_resetState(void)

static uint64_t getStorageSize(void)
{
NSNumber *storageSize = [[[NSFileManager defaultManager]
attributesOfFileSystemForPath:NSHomeDirectory()
error:nil]
objectForKey:NSFileSystemSize];
NSNumber *storageSize = [[[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:nil]
objectForKey:NSFileSystemSize];
return storageSize.unsignedLongLongValue;
}

#pragma mark - API -

static const char* monitorId(void)
{
return "DiscSpace";
}
static const char *monitorId(void) { return "DiscSpace"; }

static void setEnabled(bool isEnabled)
{
if(isEnabled != g_isEnabled)
{
if (isEnabled != g_isEnabled) {
g_isEnabled = isEnabled;
}
}

static bool isEnabled(void)
{
return g_isEnabled;
}
static bool isEnabled(void) { return g_isEnabled; }

static void addContextualInfoToEvent(KSCrash_MonitorContext* eventContext)
static void addContextualInfoToEvent(KSCrash_MonitorContext *eventContext)
{
if(g_isEnabled)
{
if (g_isEnabled) {
eventContext->System.storageSize = getStorageSize();
}
}

KSCrashMonitorAPI* kscm_discspace_getAPI(void)
KSCrashMonitorAPI *kscm_discspace_getAPI(void)
{
static KSCrashMonitorAPI api =
{
.monitorId = monitorId,
.setEnabled = setEnabled,
.isEnabled = isEnabled,
.addContextualInfoToEvent = addContextualInfoToEvent
};
static KSCrashMonitorAPI api = { .monitorId = monitorId,
.setEnabled = setEnabled,
.isEnabled = isEnabled,
.addContextualInfoToEvent = addContextualInfoToEvent };
return &api;
}

#pragma mark - Injection -

__attribute__((constructor))
static void kscm_discspace_register(void)
{
kscm_addMonitor(kscm_discspace_getAPI());
}
__attribute__((constructor)) static void kscm_discspace_register(void) { kscm_addMonitor(kscm_discspace_getAPI()); }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// KSCrashMonitor_DiscSpace.h
//
//
// Created by Gleb Linnik on 04.06.2024.
//
// Copyright (c) 2012 Karl Stenerud. All rights reserved.
Expand Down Expand Up @@ -35,7 +35,7 @@ extern "C" {

/** Access the Monitor API.
*/
KSCrashMonitorAPI* kscm_discspace_getAPI(void);
KSCrashMonitorAPI *kscm_discspace_getAPI(void);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 0b06069

Please sign in to comment.