linux/fs/ubifs
ZhaoLong Wang 7037c96d8c ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity
The UBIFS_DFS_DIR_LEN macro, which defines the maximum length of the UBIFS
debugfs directory name, has an incorrect formula and misleading comments.
The current formula is (3 + 1 + 2*2 + 1), which assumes that both UBI device
number and volume ID are limited to 2 characters. However, UBI device number
ranges from 0 to 31 (2 characters), and volume ID ranges from 0 to 127 (up
to 3 characters).

Although the current code works due to the cancellation of mathematical
errors (9 + 1 = 10, which matches the correct UBIFS_DFS_DIR_LEN value), it
can lead to confusion and potential issues in the future.

This patch aims to improve the code clarity and maintainability by making
the following changes:

1. Corrects the UBIFS_DFS_DIR_LEN macro definition to (3 + 1 + 2 + 3 + 1),
   accommodating the maximum lengths of both UBI device number and volume ID,
   plus the separators and null terminator.
2. Updates the snprintf calls to use UBIFS_DFS_DIR_LEN instead of
   UBIFS_DFS_DIR_LEN + 1, removing the unnecessary +1.
3. Modifies the error checks to compare against UBIFS_DFS_DIR_LEN using >=
   instead of >, aligning with the corrected macro definition.
4. Removes the redundant +1 in the dfs_dir_name array definitions in ubi.h
   and debug.h.

While these changes do not affect the runtime behavior, they make the code
more readable, maintainable, and less prone to future errors.

v2->v3:

 - Removes the duplicated UBIFS_DFS_DIR_LEN and UBIFS_DFS_DIR_NAME macro
   definitions in ubifs.h, as they are already defined in debug.h.

Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2024-07-12 21:52:24 +02:00
..
auth.c ubifs: auth.c: fix kernel-doc function prototype warning 2024-01-05 16:34:39 +01:00
budget.c ubifs: Reserve one leb for each journal head while doing budget 2023-02-02 21:13:40 +01:00
commit.c ubifs: Check @c->dirty_[n|p]n_cnt and @c->nroot state under @c->lp_mutex 2024-01-05 17:03:41 +01:00
compress.c ubifs: Remove return in compr_exit() 2023-04-21 22:31:03 +02:00
crypto.c fscrypt: make the bounce page pool opt-in instead of opt-out 2023-09-24 23:03:09 -07:00
debug.c ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity 2024-07-12 21:52:24 +02:00
debug.h ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity 2024-07-12 21:52:24 +02:00
dir.c ubifs: Fix unattached inode when powercut happens in creating 2024-07-12 21:41:29 +02:00
file.c ubifs: Convert populate_page() to take a folio 2024-02-25 21:08:02 +01:00
find.c ubifs: fix function pointer cast warnings 2024-02-25 21:22:21 +01:00
gc.c ubifs: read-only if LEB may always be taken in ubifs_garbage_collect 2021-12-23 22:30:38 +01:00
io.c ubifs: Fix kernel-doc 2023-02-02 21:13:53 +01:00
ioctl.c ubifs: convert to ctime accessor functions 2023-07-24 10:30:05 +02:00
journal.c ubifs: Fix unattached inode when powercut happens in creating 2024-07-12 21:41:29 +02:00
Kconfig fscrypt: Allow modular crypto algorithms 2019-12-31 10:33:51 -06:00
key.h ubifs: allow both hash and disk name to be provided in no-key names 2020-01-22 14:49:56 -08:00
log.c ubifs: remove unnecessary check in ubifs_log_start_commit 2019-07-08 19:43:51 +02:00
lprops.c ubifs: fix function pointer cast warnings 2024-02-25 21:22:21 +01:00
lpt_commit.c ubifs: Remove unreachable code in dbg_check_ltab_lnum 2024-02-25 21:29:30 +01:00
lpt.c ubifs: Fix the printing type of c->big_lpt 2020-12-13 21:57:10 +01:00
Makefile ubifs: Export filesystem error counters 2021-12-23 20:23:42 +01:00
master.c ubifs: Fix spelling mistakes 2021-06-22 09:21:39 +02:00
misc.c ubifs: Allow setting assert action as mount parameter 2018-08-15 00:25:21 +02:00
misc.h ubifs: misc.h: delete a duplicated word 2020-08-02 22:59:03 +02:00
orphan.c ubifs: dbg_orphan_check: Fix missed key type checking 2024-07-12 21:42:07 +02:00
recovery.c ubifs: Pass node length in all node dumping callers 2020-12-13 22:12:32 +01:00
replay.c ubifs: describe function parameters 2024-01-05 16:35:25 +01:00
sb.c ubifs: Default to zstd compression 2021-04-15 22:00:26 +02:00
scan.c ubifs: Pass node length in all node dumping callers 2020-12-13 22:12:32 +01:00
shrinker.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336 2019-06-05 17:37:07 +02:00
super.c This pull request contains updates for UBI and UBIFS: 2024-03-21 15:09:29 -07:00
sysfs.c ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity 2024-07-12 21:52:24 +02:00
tnc_commit.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
tnc_misc.c ubifs: dbg_check_idx_size: Fix kmemleak if loading znode failed 2024-02-25 21:40:11 +01:00
tnc.c ubifs: dbg_check_idx_size: Fix kmemleak if loading znode failed 2024-02-25 21:40:11 +01:00
ubifs-media.h ubifs: Add support for zstd compression. 2019-07-08 19:43:53 +02:00
ubifs.h ubifs: correct UBIFS_DFS_DIR_LEN macro definition and improve code clarity 2024-07-12 21:52:24 +02:00
xattr.c ubifs: Fix space leak when powercut happens in linking tmpfile 2024-07-12 21:40:47 +02:00