Drivers: hv: vmbus: Remove duplication and cleanup code in create_gpadl_header()
authorMichael Kelley <mhklinux@outlook.com>
Thu, 11 Jan 2024 16:54:50 +0000 (08:54 -0800)
committerWei Liu <wei.liu@kernel.org>
Fri, 1 Mar 2024 08:21:16 +0000 (08:21 +0000)
commit8db0edc4acb1c654e4c115a3978fb2681c5bfb74
tree5bd1961e14c3dbf4216753e94fa86e73133abde9
parent20ee2ae8c58990ca9e98954b7ac2b66c53a0310e
Drivers: hv: vmbus: Remove duplication and cleanup code in create_gpadl_header()

create_gpadl_header() creates a message header, and one or more message
bodies if the number of GPADL entries exceeds what fits in the
header. Currently the code for creating the message header is
duplicated in the two halves of the main "if" statement governing
whether message bodies are created.

Eliminate the duplication by making minor tweaks to the logic and
associated comments. While here, simplify the handling of memory
allocation errors, and use umin() instead of open coding it.

For ease of review, the indentation of sizable chunks of code is
*not* changed.  A follow-on patch updates only the indentation.

No functional change.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Michael Kelley <mhklinux@outlook.com>
Link: https://lore.kernel.org/r/20240111165451.269418-1-mhklinux@outlook.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <20240111165451.269418-1-mhklinux@outlook.com>
drivers/hv/channel.c