Skip to contentSkip to conversation

printf: Remove unused 'bprintf'

PATCH Superseded [email protected] 3 participants 7 messages Oct 2, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 printf: Remove unused 'bprintf'

From: "Dr. David Alan Gilbert" <[email protected]>

bprintf is unused. Remove it.

It was added in
commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

---
 include/linux/string.h |  1 -
 lib/vsprintf.c         | 23 -----------------------
 2 files changed, 24 deletions(-)
include/linux/string.h +0 -1
index 0dd27afcfaf7..493ac4862c77 100644
@@ -335,7 +335,6 @@ int __sysfs_match_string(const char * const *array, size_t n, const char *s);
 #ifdef CONFIG_BINARY_PRINTF
 int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
 int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
-int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4);
 #endif
 
 extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
lib/vsprintf.c +0 -23
index 09f022ba1c05..d072cd59eb6a 100644
@@ -3383,29 +3383,6 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
 }
 EXPORT_SYMBOL_GPL(bstr_printf);
 
-/**
- * bprintf - Parse a format string and place args' binary value in a buffer
- * @bin_buf: The buffer to place args' binary value
- * @size: The size of the buffer(by words(32bits), not characters)
- * @fmt: The format string to use
- * @...: Arguments for the format string
- *
- * The function returns the number of words(u32) written
- * into @bin_buf.
- */
-int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...)
-{
-	va_list args;
-	int ret;
-
-	va_start(args, fmt);
-	ret = vbin_printf(bin_buf, size, fmt, args);
-	va_end(args);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(bprintf);
-
 #endif /* CONFIG_BINARY_PRINTF */
 
 /**
Signature · 1 line
2.46.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · On Wed, Oct 02, 2024 at 02:21:25AM +0100, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

bprintf is unused. Remove it.

bprintf()

Quoted 5 lines

It was added in
commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

Please, rewrap these lines to use more room on each line.

...

I am not familiar with tricks in BPF or ftrace code where this actually might be implicitly called via a macro, but brief grep gives nothing that might point to that. Hence, with the amended commit message

P.S. I hope we may rely in CIs to report issues soon, if any.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 6 lines · * Andy Shevchenko ([email protected]) wrote:
Quoted 3 lines · On Wed, Oct 02, 2024 at 02:21:25AM +0100, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

bprintf is unused. Remove it.

bprintf()

OK.

Quoted 7 lines
Quoted 5 lines

It was added in
commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

Please, rewrap these lines to use more room on each line.

Something like this? :

bprintf() is unused. Remove it. It was added in

commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

Quoted 5 lines

...

I am not familiar with tricks in BPF or ftrace code where this actually might be implicitly called via a macro, but brief grep gives nothing that might point to that.

I've got an all-yes build (well, most after I took out broken stuff) booting with it, and it has CONFIG_BINARY_PRINTF=y and CONFIG_FTRACE=y .

trace_seq.c uses seq_buf_bprintf which uses bstr_printf rather than the plain bprintf() that I've deleted.
Not sure where to dig in BPF, but I've had a fairly good grep around.

Quoted 3 lines

Hence, with the amended commit message

Thanks!

Quoted 1 line

P.S. I hope we may rely in CIs to report issues soon, if any.

Sure

Dave

Quoted 6 lines
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#3 lore raw
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Andy Shevchenko ([email protected]) wrote:
Quoted 3 lines · On Wed, Oct 02, 2024 at 02:21:25AM +0100, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

bprintf is unused. Remove it.

bprintf()

OK.

Quoted 7 lines
Quoted 5 lines

It was added in
commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

Please, rewrap these lines to use more room on each line.

Quoted 8 lines

Something like this? :

bprintf() is unused. Remove it. It was added in

commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

You have two blank lines in the middle, do you really need them? I would put it like this

bprintf() is unused. Remove it. It was added in the commit 4370aa4aa753 ("vsprintf: add binary printf") but as far as I can see was never used, unlike the other two functions in that patch.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 21 lines · * Andy Shevchenko ([email protected]) wrote:
Quoted 19 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Andy Shevchenko ([email protected]) wrote:
Quoted 3 lines · On Wed, Oct 02, 2024 at 02:21:25AM +0100, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

bprintf is unused. Remove it.

bprintf()

OK.

Quoted 7 lines
Quoted 5 lines

It was added in
commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

Please, rewrap these lines to use more room on each line.

Something like this? :

Quoted 8 lines
Quoted 6 lines

bprintf() is unused. Remove it. It was added in

commit 4370aa4aa753 ("vsprintf: add binary printf")

but as far as I can see was never used, unlike the other two functions in that patch.

You have two blank lines in the middle, do you really need them?

No, I was just trying to keep the commit reference separate, I'm never quite sure what checkpatch gets upset by.

Quoted 5 lines

I would put it like this

bprintf() is unused. Remove it. It was added in the commit 4370aa4aa753 ("vsprintf: add binary printf") but as far as I can see was never used, unlike the other two functions in that patch.

Sure, I can send a v2 like that.

Dave

Quoted 5 lines
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
maintainer
#5 lore raw
In reply to Dr. David Alan Gilbert
Quoted 10 lines · On Wed, 2 Oct 2024 14:31:19 +0000 "Dr. David Alan Gilbert" <[email protected]>…
Quoted 3 lines

I am not familiar with tricks in BPF or ftrace code where this actually might be implicitly called via a macro, but brief grep gives nothing that might point to that.

I've got an all-yes build (well, most after I took out broken stuff) booting with it, and it has CONFIG_BINARY_PRINTF=y and CONFIG_FTRACE=y .

trace_seq.c uses seq_buf_bprintf which uses bstr_printf rather than the plain bprintf() that I've deleted.
Not sure where to dig in BPF, but I've had a fairly good grep around.

I believe it is safe to delete. It looks like bprintf() was added for completeness, where as everything is just using the vbin_printf() directly. bprintf() is nothing more than a wrapper around it in case someone wanted to use binary prints directly. But I'm not sure there's a good use case for it, as all users would likely need to add some code around it for processing (like trace.c does).

Send a v2 and I could take it for v6.13.

-- Steve

#6 lore raw
Quoted 14 lines · * Steven Rostedt ([email protected]) wrote:
Quoted 10 lines · On Wed, 2 Oct 2024 14:31:19 +0000 "Dr. David Alan Gilbert" <[email protected]>…
Quoted 3 lines

I am not familiar with tricks in BPF or ftrace code where this actually might be implicitly called via a macro, but brief grep gives nothing that might point to that.

I've got an all-yes build (well, most after I took out broken stuff) booting with it, and it has CONFIG_BINARY_PRINTF=y and CONFIG_FTRACE=y .

trace_seq.c uses seq_buf_bprintf which uses bstr_printf rather than the plain bprintf() that I've deleted.
Not sure where to dig in BPF, but I've had a fairly good grep around.

Quoted 8 lines

I believe it is safe to delete. It looks like bprintf() was added for completeness, where as everything is just using the vbin_printf() directly. bprintf() is nothing more than a wrapper around it in case someone wanted to use binary prints directly. But I'm not sure there's a good use case for it, as all users would likely need to add some code around it for processing (like trace.c does).

Send a v2 and I could take it for v6.13.

Thanks,

Just posted, message-id [email protected]

Dave

Quoted 2 lines

-- Steve

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/