git: 6332e0f1a4b3 - main - CAM: Remove return value from xpt_path_sbuf()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Nov 2023 20:17:03 UTC
The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=6332e0f1a4b34707654d6ae2cd3c1e8799970d0b commit 6332e0f1a4b34707654d6ae2cd3c1e8799970d0b Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2023-11-22 20:10:57 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2023-11-22 20:10:57 +0000 CAM: Remove return value from xpt_path_sbuf() It is wrong to call sbuf_len() on third-party sbuf. If that sbuf has a drain function, it ends up in assertion. But even would it work, it would return not newly written length, but the full one. Searching through the sources I don't see this value used. --- sys/cam/cam_xpt.c | 11 ++++------- sys/cam/cam_xpt.h | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 83fef42453fa..22d6c89f5b46 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -3743,19 +3743,18 @@ xpt_print(struct cam_path *path, const char *fmt, ...) sbuf_delete(&sb); } -int +char * xpt_path_string(struct cam_path *path, char *str, size_t str_len) { struct sbuf sb; - int len; sbuf_new(&sb, str, str_len, 0); - len = xpt_path_sbuf(path, &sb); + xpt_path_sbuf(path, &sb); sbuf_finish(&sb); - return (len); + return (str); } -int +void xpt_path_sbuf(struct cam_path *path, struct sbuf *sb) { @@ -3786,8 +3785,6 @@ xpt_path_sbuf(struct cam_path *path, struct sbuf *sb) else sbuf_printf(sb, "X): "); } - - return(sbuf_len(sb)); } path_id_t diff --git a/sys/cam/cam_xpt.h b/sys/cam/cam_xpt.h index 3c8d385fe33b..06ef52580120 100644 --- a/sys/cam/cam_xpt.h +++ b/sys/cam/cam_xpt.h @@ -102,9 +102,9 @@ int xpt_path_comp(struct cam_path *path1, struct cam_path *path2); int xpt_path_comp_dev(struct cam_path *path, struct cam_ed *dev); -int xpt_path_string(struct cam_path *path, char *str, +char * xpt_path_string(struct cam_path *path, char *str, size_t str_len); -int xpt_path_sbuf(struct cam_path *path, struct sbuf *sb); +void xpt_path_sbuf(struct cam_path *path, struct sbuf *sb); path_id_t xpt_path_path_id(struct cam_path *path); target_id_t xpt_path_target_id(struct cam_path *path); lun_id_t xpt_path_lun_id(struct cam_path *path);