Skip to content

Commit 2138e89

Browse files
Dan Carpenterhubcapsc
authored andcommitted
fs/orangefs: Allow 2 more characters in do_c_string()
The do_k_string() and do_c_string() functions do essentially the same thing which is they add a string and a comma onto the end of an existing string. At the end, the caller will overwrite the last comma with a newline. Later, in orangefs_kernel_debug_init(), we add a newline to the string. The change to do_k_string() is just cosmetic. I moved the "- 1" to the other side of the comparison and made it "+ 1". This has no effect on runtime, I just wanted the functions to match each other and the rest of the file. However in do_c_string(), I removed the "- 2" which allows us to print two extra characters. I noticed this issue while reviewing the code and I doubt affects anything in real life. My guess is that this was double counting the comma and the newline. The "+ 1" accounts for the newline, and the caller will delete the final comma which ensures there is enough space for the newline. Removing the "- 2" lets us print 2 more characters, but mainly it makes the code more consistent and understandable for reviewers. Fixes: 44f4641 ("orangefs: clean up debugfs globals") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Mike Marshall <[email protected]>
1 parent 313bf5b commit 2138e89

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/orangefs/orangefs-debugfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,8 @@ static void do_k_string(void *k_mask, int index)
769769

770770
if (*mask & s_kmod_keyword_mask_map[index].mask_val) {
771771
if ((strlen(kernel_debug_string) +
772-
strlen(s_kmod_keyword_mask_map[index].keyword))
773-
< ORANGEFS_MAX_DEBUG_STRING_LEN - 1) {
772+
strlen(s_kmod_keyword_mask_map[index].keyword) + 1)
773+
< ORANGEFS_MAX_DEBUG_STRING_LEN) {
774774
strcat(kernel_debug_string,
775775
s_kmod_keyword_mask_map[index].keyword);
776776
strcat(kernel_debug_string, ",");
@@ -797,7 +797,7 @@ static void do_c_string(void *c_mask, int index)
797797
(mask->mask2 & cdm_array[index].mask2)) {
798798
if ((strlen(client_debug_string) +
799799
strlen(cdm_array[index].keyword) + 1)
800-
< ORANGEFS_MAX_DEBUG_STRING_LEN - 2) {
800+
< ORANGEFS_MAX_DEBUG_STRING_LEN) {
801801
strcat(client_debug_string,
802802
cdm_array[index].keyword);
803803
strcat(client_debug_string, ",");

0 commit comments

Comments
 (0)