Skip to content

Commit a48ba9c

Browse files
committed
Fix header non-static/inline functions.
Functions defined in headers should be static at least, and probably inline too in most cases. Towards this end, move non-trivial function definitions in compat.h (which has nothing to do with compatibity) directly into ipt_NETFLOW.c as static, and the trivial ones to static inline in the header. Signed-off-by: Jaco Kroon <jaco@uls.co.za>
1 parent df33a7d commit a48ba9c

File tree

2 files changed

+38
-36
lines changed

2 files changed

+38
-36
lines changed

compat.h

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct timeval {
220220
long tv_usec; /* microseconds */
221221
};
222222

223-
unsigned long timeval_to_jiffies(const struct timeval *tv)
223+
static inline unsigned long timeval_to_jiffies(const struct timeval *tv)
224224
{
225225
return timespec64_to_jiffies(&(struct timespec64){
226226
tv->tv_sec,
@@ -387,7 +387,7 @@ static int sockaddr_cmp(const struct sockaddr_storage *sa1, const struct sockadd
387387
#ifndef IN6PTON_XDIGIT
388388
#define hex_to_bin compat_hex_to_bin
389389
/* lib/hexdump.c */
390-
int hex_to_bin(char ch)
390+
static inline int hex_to_bin(char ch)
391391
{
392392
if ((ch >= '0') && (ch <= '9'))
393393
return ch - '0';
@@ -716,40 +716,6 @@ static inline void do_gettimeofday(struct timeval *tv)
716716
}
717717
#endif
718718

719-
#define TOLOWER(x) ((x) | 0x20)
720-
unsigned long long strtoul(const char *cp, char **endp, unsigned int base)
721-
{
722-
unsigned long long result = 0;
723-
724-
if (!base) {
725-
if (cp[0] == '0') {
726-
if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2]))
727-
base = 16;
728-
else
729-
base = 8;
730-
} else {
731-
base = 10;
732-
}
733-
}
734-
735-
if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x')
736-
cp += 2;
737-
738-
while (isxdigit(*cp)) {
739-
unsigned int value;
740-
741-
value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10;
742-
if (value >= base)
743-
break;
744-
result = result * base + value;
745-
cp++;
746-
}
747-
if (endp)
748-
*endp = (char *)cp;
749-
750-
return result;
751-
}
752-
753719
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0)) \
754720
|| ((LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,220)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0)))
755721
/*

ipt_NETFLOW.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,42 @@ static inline int mask2bits(__be32 mask) {
356356
return n;
357357
}
358358

359+
#define TOLOWER(x) ((x) | 0x20)
360+
static
361+
unsigned long long strtoul(const char *cp, char **endp, unsigned int base)
362+
{
363+
unsigned long long result = 0;
364+
365+
if (!base) {
366+
if (cp[0] == '0') {
367+
if (TOLOWER(cp[1]) == 'x' && isxdigit(cp[2]))
368+
base = 16;
369+
else
370+
base = 8;
371+
} else {
372+
base = 10;
373+
}
374+
}
375+
376+
if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x')
377+
cp += 2;
378+
379+
while (isxdigit(*cp)) {
380+
unsigned int value;
381+
382+
value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10;
383+
if (value >= base)
384+
break;
385+
result = result * base + value;
386+
cp++;
387+
}
388+
if (endp)
389+
*endp = (char *)cp;
390+
391+
return result;
392+
}
393+
394+
359395
/* under that lock worker is always stopped and not rescheduled,
360396
* and we can call worker sub-functions manually */
361397
static DEFINE_MUTEX(worker_lock);

0 commit comments

Comments
 (0)