-
Notifications
You must be signed in to change notification settings - Fork 0
Clean up lookahead-related code #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: coderabbit_combined_20260121_augment_sentry_coderabbit_1_base_clean_up_lookahead-related_code_pr94
Are you sure you want to change the base?
Changes from all commits
8b0c671
fba02a7
9d4b9a1
316914e
d10b113
32bb106
7b01b6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -426,27 +426,16 @@ int getKeySlot(sds key) { | |
| } | ||
|
|
||
| /* Return the slot of the key in the command. | ||
| * GETSLOT_NOKEYS if no keys, GETSLOT_CROSSSLOT if cross slot, otherwise the slot number. */ | ||
| * INVALID_CLUSTER_SLOT if no keys, CLUSTER_CROSSSLOT if cross slot, otherwise the slot number. */ | ||
| int getSlotFromCommand(struct redisCommand *cmd, robj **argv, int argc) { | ||
| int slot = GETSLOT_NOKEYS; | ||
| if (!cmd || !server.cluster_enabled) return slot; | ||
| if (!cmd || !server.cluster_enabled) return INVALID_CLUSTER_SLOT; | ||
|
|
||
| /* Get the keys from the command */ | ||
| getKeysResult result = GETKEYS_RESULT_INIT; | ||
| int numkeys = getKeysFromCommand(cmd, argv, argc, &result); | ||
| keyReference *keyindex = result.keys; | ||
|
|
||
| /* Get slot of each key and check if they are all the same */ | ||
| for (int j = 0; j < numkeys; j++) { | ||
| robj *thiskey = argv[keyindex[j].pos]; | ||
| int thisslot = keyHashSlot((char*)thiskey->ptr, sdslen(thiskey->ptr)); | ||
| if (slot == GETSLOT_NOKEYS) { | ||
| slot = thisslot; | ||
| } else if (slot != thisslot) { | ||
| slot = GETSLOT_CROSSSLOT; /* Mark as cross slot */ | ||
| break; | ||
| } | ||
| } | ||
| getKeysFromCommand(cmd, argv, argc, &result); | ||
|
|
||
| /* Extract slot from the keys result. */ | ||
| int slot = extractSlotFromKeysResult(argv, &result); | ||
|
Comment on lines
+437
to
+438
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -n -A 30 'int extractSlotFromKeysResult' src/cluster.cRepository: qodo-benchmark/redis-combined-coderabbit Length of output: 1398 Critical: Off-by-one error in The
Both occur when the loop accesses index 🤖 Prompt for AI Agents |
||
| getKeysFreeResult(&result); | ||
| return slot; | ||
| } | ||
|
|
@@ -3209,10 +3198,9 @@ int extractKeysAndSlot(struct redisCommand *cmd, robj **argv, int argc, | |
| } | ||
| } | ||
|
|
||
| *slot = INVALID_CLUSTER_SLOT; | ||
| if (num_keys >= 0) | ||
| if (num_keys > 0) { | ||
| *slot = extractSlotFromKeysResult(argv, result); | ||
|
|
||
| } | ||
| return num_keys; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix off‑by‑one and remove deprecated malloc/free.
Line 1112 iterates with
<= keys_result->numkeys, which reads/writes one past the end ofkeys_result->keys(andslot_buffer). Also,malloc/freeare deprecated in this codebase and currently fail CI. The buffer isn’t used, so removing it fixes both issues.🛠️ Proposed fix
🧰 Tools
🪛 GitHub Actions: CI
[error] 1110-1124: cluster.c: 'malloc' and 'free' are deprecated. The build enables -Werror, causing these deprecated-declarations to fail compilation.
🪛 GitHub Actions: Codecov
[error] 1110-1124: Compilation failed due to deprecated memory management functions: malloc and free are deprecated under -Werror. The build flags promote deprecated-declarations as errors. Adjust code to use appropriate allocation patterns or remove the deprecation (e.g., use realloc or project-specific allocators) to fix the cluster.o compilation errors.
🪛 GitHub Actions: External Server Tests
[error] 1110-1124: Werror: deprecated usage of malloc/free detected. Replacement with calloc/realloc or updated memory management required. References to malloc at 1110 and free at 1120/1124 trigger failures.
🤖 Prompt for AI Agents