libnvme: return libnvmf_tid_from_fields() as int, not a pointer - #3669
Open
martin-belanger wants to merge 1 commit into
Open
libnvme: return libnvmf_tid_from_fields() as int, not a pointer#3669martin-belanger wants to merge 1 commit into
martin-belanger wants to merge 1 commit into
Conversation
libnvmf_tid_from_fields() returned NULL on any failure, so a caller could not tell a validation error (-EINVAL, non-numeric traddr/host_traddr) from an allocation failure (-ENOMEM). Two internal callers actually got this wrong: fabrics.c's build_conn_tid() reported every failure as -EINVAL, and libnvme/src/nvme/fabrics.c's nvmf_sanitize_addrs() and the owner lookup in libnvmf_get_owner_from_fctx() reported every failure as -ENOMEM. Convert to int with an out-param, matching libnvmf_config_read()'s existing convention, and update every call site. The SWIG binding now raises a real errno-based message instead of always PyErr_NoMemory(). Also check for a partial shr_xstrdup() failure across the struct's multi-field copy, which the pointer-returning version never checked. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
libnvmf_tid_from_fields() returned NULL on any failure, so a caller could not tell a validation error (-EINVAL, non-numeric traddr/host_traddr) from an allocation failure (-ENOMEM). Two internal callers actually got this wrong: fabrics.c's build_conn_tid() reported every failure as -EINVAL, and libnvme/src/nvme/fabrics.c's nvmf_sanitize_addrs() and the owner lookup in libnvmf_get_owner_from_fctx() reported every failure as -ENOMEM.
Convert to int with an out-param, matching libnvmf_config_read()'s existing convention, and update every call site. The SWIG binding now raises a real errno-based message instead of always PyErr_NoMemory().
Also check for a partial shr_xstrdup() failure across the struct's multi-field copy, which the pointer-returning version never checked.