docs: clarify return contracts for parse_hex4 and cJSON_ReplaceItemInArray#1056
Open
JIgar-maheshwari-dev wants to merge 1 commit into
Open
Conversation
- Add doc comment above parse_hex4 explaining that returning 0 represents both valid 0x0000 and parse failures. - Document cJSON_ReplaceItemInArray return behavior in cJSON.h and cJSON.c, noting that returning cJSON_False covers both NULL inputs and out-of-bounds indices. Signed-off-by: JIgar-maheshwari-dev <maheshwarijigar656@gmail.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.
Fixes #1007
Overview
This PR adds clarifying documentation comments for
parse_hex4andcJSON_ReplaceItemInArrayto document ambiguous return values and error conditions without introducing breaking API changes.Changes Included
1. Document
parse_hex4Dual-Meaning Return (cJSON.c)0serves a dual purpose:0x0000(e.g.,\u0000).0x0000from parsing failures.2. Document
cJSON_ReplaceItemInArrayOut-of-Range Contract (cJSON.h&cJSON.c)cJSON.hand definition incJSON.c.cJSON_False(0) covers bothNULLarguments and silent failures when an index (which) is out of bounds or negative.Motivation
These edge cases were previously undocumented, making silent
cJSON_Falsereturns or0sentinel values difficult to interpret without inspecting internal source code. Adding these comments improves API clarity while preserving full backward compatibility.Verification