Skip to contentSkip to conversation

staging: vchiq_core: fix quoted strings split across lines

PATCH In review Gaston Gonzalez 2 participants 2 messages Oct 24, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 8/8 staging: vchiq_core: fix quoted strings split across lines

Quoted strings should not be split across lines. As put it in [1]:
"never break user-visible strings such as printk messages because that breaks the ability to grep for them."

While at it, fix the alignment of the arguments in the sentence.

Note: this introduce a checkpatch CHECK: line length of 123 exceeds 100 columns, as the line now is:

vchiq_loud_error("%d: service %d (%c%c%c%c) version mismatch - local (%d, min %d) vs. remote (%d, min %d)",

But now the string is grep-able and the whole function call more clear.

Reported by checkpatch.pl

[1] Documentation/process/coding-style.rst

---
 .../vc04_services/interface/vchiq_arm/vchiq_core.c     | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +3 -7
index 3af55e78f356..ab97a35e63f9 100644
@@ -1499,13 +1499,9 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header)
 	if ((service->version < version_min) || (version < service->version_min)) {
 		/* Version mismatch */
 		vchiq_loud_error_header();
-		vchiq_loud_error("%d: service %d (%c%c%c%c) "
-			"version mismatch - local (%d, min %d)"
-			" vs. remote (%d, min %d)",
-			state->id, service->localport,
-			VCHIQ_FOURCC_AS_4CHARS(fourcc),
-			service->version, service->version_min,
-			version, version_min);
+		vchiq_loud_error("%d: service %d (%c%c%c%c) version mismatch - local (%d, min %d) vs. remote (%d, min %d)",
+				 state->id, service->localport, VCHIQ_FOURCC_AS_4CHARS(fourcc),
+				 service->version, service->version_min, version, version_min);
 		vchiq_loud_error_footer();
 		vchiq_service_put(service);
 		service = NULL;
Signature · 1 line
2.33.1
#2 lore raw
Quoted 6 lines · Gaston Gonzalez

Quoted strings should not be split across lines. As put it in [1]:
"never break user-visible strings such as printk messages because that breaks the ability to grep for them."

While at it, fix the alignment of the arguments in the sentence.

Quoted 7 lines

Note: this introduce a checkpatch CHECK: line length of 123 exceeds 100 columns, as the line now is:

vchiq_loud_error("%d: service %d (%c%c%c%c) version mismatch - local (%d, min %d) vs. remote (%d, min %d)",

But now the string is grep-able and the whole function call more clear.

IMO: All of these should be changed

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h:#define VCHIQ_LOG_PREFIX KERN_INFO "vchiq: "
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#ifndef vchiq_log_error drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#define vchiq_log_error(cat, fmt, ...) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h- do { if (cat >= VCHIQ_LOG_ERROR) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h: printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#endif drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#ifndef vchiq_log_warning drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#define vchiq_log_warning(cat, fmt, ...) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h- do { if (cat >= VCHIQ_LOG_WARNING) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h: printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#endif drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#ifndef vchiq_log_info drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#define vchiq_log_info(cat, fmt, ...) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h- do { if (cat >= VCHIQ_LOG_INFO) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h: printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#endif drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#ifndef vchiq_log_trace drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#define vchiq_log_trace(cat, fmt, ...) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h- do { if (cat >= VCHIQ_LOG_TRACE) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h: printk(VCHIQ_LOG_PREFIX fmt "\n", ##__VA_ARGS__); } while (0)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#endif drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-#define vchiq_loud_error(...) \
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h- vchiq_log_error(vchiq_core_log_level, "===== " __VA_ARGS__) drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h-

I suggest using the rather more common vchiq_err, vchiq_warn, vchiq_info and if necessary vchiq_trace. Also the cat >= test is unnecessary and this should just use the more common standard logging facilities.

vchiq_loud_error is IMO unnecessary.

Also several of the uses of these macros already have '\n' terminations so that just adds unnecessary blank lines in the logging.