printk.hの奇妙なバグのアイデアを探しています。

printk.hの奇妙なバグのアイデアを探しています。

私はrhel8.4(カーネルバージョン4.18.0-305.10.2.el8_4.x86_64)のデバイスドライバに対してベンダーから提供された独自のテストコードをコンパイルしています。ドライバと対応するテストコードは、rhel6.6でテストおよびデプロイするために最初にリリースされました。

コンパイラは、システムヘッダファイルに次のコード行を含めます<linux/printk.h>

static inline __printf(1, 2) __cold
     void early_printk(const char *s, ...) { }

以下のリンクに記載されている説明に従ってformat attributefor関数を宣言します。

関数属性宣言

<linux/compiler-gcc.h>システムヘッダファイルには、次の対応する宣言があります。

#define __printf(a, b)          __attribute__((format(printf, a, b)))

カーネルはソースコードに直接含めることを禁止しており<linux/compiler-gcc.h>、経由で間接的に含めることをお勧めします<linux/compiler.h>

このファイルはインクルードされ、<linux/printk.h>システムヘッダファイルに含まれていました。独自のベンダーコードに付属のヘッダーファイルには。<linux/kernel.h><linux/compiler.h><linux/kernel.h>

上記に基づいて、コンパイラは上記の宣言で型属性の拡張を見つけることを期待できます<linux/printk.h>

static inline __printf(1, 2) __cold
         void early_printk(const char *s, ...) { }

ただし、代わりにコンパイラは型属性をエラーとしてマークします。

/usr/src/kernels/4.18.0-305.10.2.el8_4.x86_64/include/linux/printk.h:145:24: error: expected declaration specifiers or ‘...’ before numeric constant
 static inline __printf(1, 2) __cold

以下は、内部カーネルシステムファイルが含まれる順序です<linux/kernel.h><linux/printk.h>

#include <stdarg.h>
#include <linux/limits.h>
#include <linux/linkage.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/compiler.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/typecheck.h>
#include <linux/printk.h>

私はgccバージョン8.4.1 20200928を使用しています。

どんなアイデアでも大いに感謝します。

ベストアンサー1

おすすめ記事