Commit Graph

32 Commits

Author SHA1 Message Date
DL6ER
93d17a332a Merge branch 'development' into tweak/remove_global_objects
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-04-16 18:04:40 +02:00
DL6ER
6fcbce6c34 Improve code based on a full static analysis of our code. There are no real bugs, nowever, we use the obtained knowledge to improve the code such as unify declarations and function definitions, reduce the scope of local variables, mark many function arguments and local variables const when they are, fix the type expected by %x and fix one if-condition
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-04-15 22:35:14 +02:00
DL6ER
7e3b31c02a Improve code formatting in overTime.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-14 21:07:37 +01:00
DL6ER
0257b273bd Declare several more pointers to queries, domains, and clients pointers as read-only when this is currently the case.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-12 20:08:58 +01:00
DL6ER
538779d1b4 Merge branch 'development' into tweak/remove_global_objects
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-11 12:09:00 +01:00
DL6ER
32be41ed5d Declare attributes for functions in FTL. These attributes help the compiler to optimize functions calls and to check our code more carefully during compilation. See pull reqeust text for details.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-08 11:36:11 +01:00
DL6ER
8c11628e71 Skip magic byte validation when we're just about to create the entry for the first time (magic byte hasn't ben initialized yet)
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-06 18:53:33 +01:00
DL6ER
0b5d6c3eae Shorten name of structs. This is only of cosmetic nature and does not change any functionality in the code.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-06 17:47:34 +01:00
DL6ER
6466a69da4 Remove globally defined clients array.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-06 16:52:20 +01:00
DL6ER
810e36bef8 Remove globally defined queries array.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-03-06 16:26:54 +01:00
DL6ER
2f74929d2a Merge branch 'development' into tweak/overhaul_overTime
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-18 19:00:09 +01:00
Mcat12
83dc51aba1 Add license header to overTime.c
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-15 20:35:06 -08:00
DL6ER
28d16ddf45 Merge branch 'tweak/overhaul_overTime' of github.com:pi-hole/FTL into tweak/overhaul_overTime 2019-02-15 20:47:36 +01:00
DL6ER
17de954ac4 Unify debug messages and slight additional tweaks for overTime.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-15 20:47:09 +01:00
Mcat12
aadd0657af Share the min time during query GC with overTime GC
This ensures that all queries which do not fit within the shifted
overTime intervals are removed. Previously, there were warnings about
queries being too old to fit in the new overTime slots:
```
WARN: overTime timeidx correction failed (0: 5 / 6)
```

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-14 18:08:18 -08:00
DL6ER
0995c5ad8b Fix for the GC routines
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-14 06:38:44 +01:00
DL6ER
130a12543e Correct time indices of queries in moveOverTimeMemory()
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-13 21:13:24 +01:00
DL6ER
175c0a33e1 GC: Shift SHOULD timestemp into the future by the amount GC is running earlier to properly align to a full hour
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-12 21:08:11 +01:00
DL6ER
7d4dc164b5 Fix boundary we're checking against in getOverTimeID()
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-12 21:00:33 +01:00
DL6ER
9cac627d85 Add more debugging output + ensure the initial overTime interval is set up correctly
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-12 19:29:41 +01:00
DL6ER
c5bf31d064 Also explicitly check if overTime index is larger than OVERTIME_SLOTS-1 to ensure we're not accidentially accessing other memory
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-12 07:17:26 +01:00
Mcat12
3d78765bb9 Simplify size argument of memmove
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-11 20:02:28 -08:00
Mcat12
bcba2a16af Fix out of bounds array access in initSlot
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-11 19:00:48 -08:00
Mcat12
34bd5cbe30 Improve overTime integer casts
Also removed the overTime client prefix macro, and clarified order of
operations when calculating overTime memory size

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-11 18:41:36 -08:00
DL6ER
0bcbdc8130 Warn if we would return a negative overTime ID + fix a small bug in config.c where an uninitialised value was created by a stack allocation and used in getline()
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-11 21:00:55 +01:00
DL6ER
e3b6336d43 Explicitly set left over memory after memmove'ing client's overTime data to zero
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-11 18:26:04 +01:00
Mcat12
3d9249dc4c Remove some loud logging
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-10 14:33:44 -08:00
Mcat12
5b4bce9add Make sure to allocate the extra overTime slot during initialization
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-10 14:15:14 -08:00
Mcat12
3cc4cca280 Remove OVERTIME_NOT_AVAILABLE
There is now no case where the overTime ID is invalid. GC will run
before the overTime slots run out.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-10 13:55:10 -08:00
Mcat12
e4defd4b65 Start overTime slots in the interval FTL starts in, and fix calculations
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-10 13:47:46 -08:00
Mcat12
826e52e4a5 Initialize loop variable in initOverTime
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
2019-02-10 12:12:00 -08:00
DL6ER
f4fa76440b Add overTime.c
Signed-off-by: DL6ER <dl6er@dl6er.de>
2019-02-10 12:54:18 +01:00