Skip to content

Commit e2d8129

Browse files
MIN() and MAX()
1 parent 311a636 commit e2d8129

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/eggdrop.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,13 @@ enum {
735735
# define STRINGIFY1(x) #x
736736
#endif
737737

738+
#ifndef MIN
739+
#define MIN(a,b) (((a)<(b))?(a):(b))
740+
#endif
741+
#ifndef MAX
742+
#define MAX(a,b) (((a)>(b))?(a):(b))
743+
#endif
744+
738745
#ifdef EGG_TDNS
739746
#include <pthread.h>
740747
#define DTN_TYPE_HOSTBYIP 0

src/misc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,13 @@ void putlog (int type, char *chname, const char *format, ...)
597597
fputs(out, logs[i].f);
598598
size_t l = strlen(out + tsl);
599599
if (l > logs[i].szlast_len) {
600-
if (!logs[i].szlast_len)
601-
logs[i].szlast_len = 128;
602-
else if (logs[i].szlast_len < LOGLINELEN)
600+
if (!logs[i].szlast_len) {
601+
logs[i].szlast_len = MIN(MAX(l, 128), LOGLINELEN);
602+
logs[i].szlast = nrealloc(logs[i].szlast, logs[i].szlast_len);
603+
} else if (logs[i].szlast_len < LOGLINELEN) {
603604
logs[i].szlast_len = MIN(MAX(l, logs[i].szlast_len << 1), LOGLINELEN);
604-
logs[i].szlast = nrealloc(logs[i].szlast, logs[i].szlast_len);
605+
logs[i].szlast = nrealloc(logs[i].szlast, logs[i].szlast_len);
606+
}
605607
}
606608
strlcpy(logs[i].szlast, out + tsl, logs[i].szlast_len);
607609
}

src/mod/server.mod/servmsg.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,6 @@ static int tryauthenticate(char *from, char *msg)
13421342
char *s;
13431343
/* 400-byte chunk, see: https://ircv3.net/specs/extensions/sasl-3.1.html
13441344
* base64 padding */
1345-
#ifndef MAX
1346-
#define MAX(a,b) (((a)>(b))?(a):(b))
1347-
#endif
13481345
unsigned char dst[((MAX((sizeof src), 400) + 2) / 3) << 2] = "";
13491346
#ifdef HAVE_EVP_PKEY_GET1_EC_KEY
13501347
int olen;

0 commit comments

Comments
 (0)