Permalink
Browse files

Remove some (near-)duplicate code

  • Loading branch information...
dmoagx committed Feb 21, 2018
1 parent 6b00f5f commit 3a944d7867c750c29e02e2619d72694bdbfb0b2a
Showing with 4 additions and 11 deletions.
  1. +4 −11 Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
@@ -38,6 +38,7 @@
#include <string.h>
#include <stdlib.h>
#include <dlfcn.h>
#import "SPMySQLUtilities.h"
// Thread flag constant
static pthread_key_t mySQLThreadInitFlagKey;
@@ -477,14 +478,6 @@ + (NSString *)findSocketPath
const char *__crashreporter_info__ = NULL;
asm(".desc ___crashreporter_info__, 0x10");
static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime)
{
uint64_t elapsedTime_t = mach_absolute_time() - comparisonTime;
Nanoseconds elapsedTime = AbsoluteToNanoseconds(*(AbsoluteTime *)&(elapsedTime_t));
return (UnsignedWideToUInt64(elapsedTime) / 1000ULL);
}
@implementation SPMySQLConnection (PrivateAPI)
/**
@@ -496,8 +489,8 @@ - (BOOL)_connect
// If a connection is already active in some form, throw an exception
if (state != SPMySQLDisconnected && state != SPMySQLConnectionLostInBackground) {
@synchronized (self) {
uint64_t diff = _elapsedMicroSecondsSinceAbsoluteTime(initialConnectTime);
asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lluµs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
double diff = _elapsedSecondsSinceAbsoluteTime(initialConnectTime);
asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lfs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
__builtin_trap();
}
[NSException raise:NSInternalInconsistencyException format:@"Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).", state];
@@ -1249,7 +1242,7 @@ void PasswordCallback(MYSQL *mysql, const char *plugin, void (^with_password)(co
* The implementation is taken from the original memset_s proposal:
* http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1381.pdf
*/
errno_t LegacyMemsetS(void *s, rsize_t smax, int c, rsize_t n)
errno_t LegacyMemsetS(void *s, rsize_t smax __attribute__((unused)), int c, rsize_t n)
{
volatile unsigned char * addr = (volatile unsigned char *)s;
while(n--) *addr++ = (unsigned char)c;

0 comments on commit 3a944d7

Please sign in to comment.