[PATCH -next,V2] cachefiles: support to disable assert macro

WoZ1zh1 posted 1 patch 2 years, 1 month ago
fs/cachefiles/Kconfig    | 11 +++++++++++
fs/cachefiles/internal.h |  2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
[PATCH -next,V2] cachefiles: support to disable assert macro
Posted by WoZ1zh1 2 years, 1 month ago
In fs/cachefiles/internal.h, ASSERT macro is enabled by default and can
not be disabled, then assert failure will crash the kernel as the BUG()
is included in the ASSERT macro. Therefore, add CACHEFILES_ASSERT to
control it.

Signed-off-by: WoZ1zh1 <wozizhi@huawei.com>
---
 fs/cachefiles/Kconfig    | 11 +++++++++++
 fs/cachefiles/internal.h |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/cachefiles/Kconfig b/fs/cachefiles/Kconfig
index 8df715640a48..83d8ec3ba2d8 100644
--- a/fs/cachefiles/Kconfig
+++ b/fs/cachefiles/Kconfig
@@ -38,3 +38,14 @@ config CACHEFILES_ONDEMAND
 	  and is delegated to userspace.
 
 	  If unsure, say N.
+
+config CACHEFILES_ASSERT
+	bool "CACHEFILES asserts"
+	default n
+	depends on CACHEFILES
+	help
+	  Support the ASSERT mode for failure behavior.
+	  Say N here to disable the ASSERT by default.
+	  Say Y to add assertion checks in some places. But the assertion
+	  failure will result in fatal errors that BUG() the kernel.
+
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 2ad58c465208..263b1f13e943 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -425,7 +425,7 @@ do {							\
 #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
 #endif
 
-#if 1 /* defined(__KDEBUGALL) */
+#ifdef CONFIG_CACHEFILES_ASSERT
 
 #define ASSERT(X)							\
 do {									\
-- 
2.39.2
Re: [PATCH -next,V2] cachefiles: support to disable assert macro
Posted by Zizhi Wo 2 years, 1 month ago
friendly ping

在 2023/11/2 0:34, WoZ1zh1 写道:
> In fs/cachefiles/internal.h, ASSERT macro is enabled by default and can
> not be disabled, then assert failure will crash the kernel as the BUG()
> is included in the ASSERT macro. Therefore, add CACHEFILES_ASSERT to
> control it.
>
> Signed-off-by: WoZ1zh1 <wozizhi@huawei.com>
> ---
>   fs/cachefiles/Kconfig    | 11 +++++++++++
>   fs/cachefiles/internal.h |  2 +-
>   2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cachefiles/Kconfig b/fs/cachefiles/Kconfig
> index 8df715640a48..83d8ec3ba2d8 100644
> --- a/fs/cachefiles/Kconfig
> +++ b/fs/cachefiles/Kconfig
> @@ -38,3 +38,14 @@ config CACHEFILES_ONDEMAND
>   	  and is delegated to userspace.
>   
>   	  If unsure, say N.
> +
> +config CACHEFILES_ASSERT
> +	bool "CACHEFILES asserts"
> +	default n
> +	depends on CACHEFILES
> +	help
> +	  Support the ASSERT mode for failure behavior.
> +	  Say N here to disable the ASSERT by default.
> +	  Say Y to add assertion checks in some places. But the assertion
> +	  failure will result in fatal errors that BUG() the kernel.
> +
> diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
> index 2ad58c465208..263b1f13e943 100644
> --- a/fs/cachefiles/internal.h
> +++ b/fs/cachefiles/internal.h
> @@ -425,7 +425,7 @@ do {							\
>   #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
>   #endif
>   
> -#if 1 /* defined(__KDEBUGALL) */
> +#ifdef CONFIG_CACHEFILES_ASSERT
>   
>   #define ASSERT(X)							\
>   do {									\
Re: [PATCH -next,V2] cachefiles: support to disable assert macro
Posted by Zizhi Wo 2 years, 1 month ago
friendly ping

在 2023/11/7 18:17, Zizhi Wo 写道:
> friendly ping
> 
> 在 2023/11/2 0:34, WoZ1zh1 写道:
>> In fs/cachefiles/internal.h, ASSERT macro is enabled by default and can
>> not be disabled, then assert failure will crash the kernel as the BUG()
>> is included in the ASSERT macro. Therefore, add CACHEFILES_ASSERT to
>> control it.
>>
>> Signed-off-by: WoZ1zh1 <wozizhi@huawei.com>
>> ---
>>   fs/cachefiles/Kconfig    | 11 +++++++++++
>>   fs/cachefiles/internal.h |  2 +-
>>   2 files changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/cachefiles/Kconfig b/fs/cachefiles/Kconfig
>> index 8df715640a48..83d8ec3ba2d8 100644
>> --- a/fs/cachefiles/Kconfig
>> +++ b/fs/cachefiles/Kconfig
>> @@ -38,3 +38,14 @@ config CACHEFILES_ONDEMAND
>>         and is delegated to userspace.
>>         If unsure, say N.
>> +
>> +config CACHEFILES_ASSERT
>> +    bool "CACHEFILES asserts"
>> +    default n
>> +    depends on CACHEFILES
>> +    help
>> +      Support the ASSERT mode for failure behavior.
>> +      Say N here to disable the ASSERT by default.
>> +      Say Y to add assertion checks in some places. But the assertion
>> +      failure will result in fatal errors that BUG() the kernel.
>> +
>> diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
>> index 2ad58c465208..263b1f13e943 100644
>> --- a/fs/cachefiles/internal.h
>> +++ b/fs/cachefiles/internal.h
>> @@ -425,7 +425,7 @@ do {                            \
>>   #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
>>   #endif
>> -#if 1 /* defined(__KDEBUGALL) */
>> +#ifdef CONFIG_CACHEFILES_ASSERT
>>   #define ASSERT(X)                            \
>>   do {                                    \
Re: [PATCH -next,V2] cachefiles: support to disable assert macro
Posted by Zizhi Wo 1 year, 11 months ago
friendly ping

在 2023/11/30 10:49, Zizhi Wo 写道:
> friendly ping
> 
> 在 2023/11/7 18:17, Zizhi Wo 写道:
>> friendly ping
>>
>> 在 2023/11/2 0:34, WoZ1zh1 写道:
>>> In fs/cachefiles/internal.h, ASSERT macro is enabled by default and can
>>> not be disabled, then assert failure will crash the kernel as the BUG()
>>> is included in the ASSERT macro. Therefore, add CACHEFILES_ASSERT to
>>> control it.
>>>
>>> Signed-off-by: WoZ1zh1 <wozizhi@huawei.com>
>>> ---
>>>   fs/cachefiles/Kconfig    | 11 +++++++++++
>>>   fs/cachefiles/internal.h |  2 +-
>>>   2 files changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/fs/cachefiles/Kconfig b/fs/cachefiles/Kconfig
>>> index 8df715640a48..83d8ec3ba2d8 100644
>>> --- a/fs/cachefiles/Kconfig
>>> +++ b/fs/cachefiles/Kconfig
>>> @@ -38,3 +38,14 @@ config CACHEFILES_ONDEMAND
>>>         and is delegated to userspace.
>>>         If unsure, say N.
>>> +
>>> +config CACHEFILES_ASSERT
>>> +    bool "CACHEFILES asserts"
>>> +    default n
>>> +    depends on CACHEFILES
>>> +    help
>>> +      Support the ASSERT mode for failure behavior.
>>> +      Say N here to disable the ASSERT by default.
>>> +      Say Y to add assertion checks in some places. But the assertion
>>> +      failure will result in fatal errors that BUG() the kernel.
>>> +
>>> diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
>>> index 2ad58c465208..263b1f13e943 100644
>>> --- a/fs/cachefiles/internal.h
>>> +++ b/fs/cachefiles/internal.h
>>> @@ -425,7 +425,7 @@ do {                            \
>>>   #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__)
>>>   #endif
>>> -#if 1 /* defined(__KDEBUGALL) */
>>> +#ifdef CONFIG_CACHEFILES_ASSERT
>>>   #define ASSERT(X)                            \
>>>   do {                                    \