]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins/solidigm: use static log macro to calc bitmask
authorDaniel Wagner <dwagner@suse.de>
Thu, 21 Sep 2023 07:17:12 +0000 (09:17 +0200)
committerDaniel Wagner <wagi@monom.org>
Thu, 21 Sep 2023 07:25:46 +0000 (09:25 +0200)
The mask is using the log2 function which pulls in the libm. The library
is not always available, e.g when building statically. This makes the
whole build logic way to complex for something like this.

Instead calculating during runtime the bitmask just use the static ilog
macros from ccan.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
plugins/solidigm/solidigm-telemetry/nlog.c

index 43b8918f1f14e7acbe9ce9d54929c4fc3db49210..926772b26cdce4734a27d3bc2ee4ebd2c4c17775 100644 (file)
@@ -8,15 +8,16 @@
 #include "nlog.h"
 #include "config.h"
 #include <string.h>
-#include <math.h>
 #include <stdio.h>
 
+#include "ccan/ilog/ilog.h"
+
 #define LOG_ENTRY_HEADER_SIZE 1
 #define LOG_ENTRY_TIMESTAMP_SIZE 2
 #define LOG_ENTRY_NUM_ARGS_MAX 8
 #define LOG_ENTRY_MAX_SIZE (LOG_ENTRY_HEADER_SIZE + LOG_ENTRY_TIMESTAMP_SIZE + \
                            LOG_ENTRY_NUM_ARGS_MAX)
-#define NUM_ARGS_MASK ((1 << ((int)log2(LOG_ENTRY_NUM_ARGS_MAX)+1)) - 1)
+#define NUM_ARGS_MASK ((1 << ((int)STATIC_ILOG_32(LOG_ENTRY_NUM_ARGS_MAX))) - 1)
 #define MAX_HEADER_MISMATCH_TRACK 10
 
 static int formats_find(struct json_object *formats, uint32_t val, struct json_object **format)