按源验证tooldata低索引写入
源依据:LinuxCNC src/emc/tooldata/tooldata_mmap.cc 的 tooldata_put() 仅在 idx > last_index 时返回 IDX_NEW 并更新 last_index,否则返回 IDX_OK。 结论:wasm-safe tooldata mmap probe 增加低于当前 last_index 的写入断言,确认返回 IDX_OK、last_index 不变且数据可读回,减少 tooldata_mmap 后端替换风险。 检查:./test-linuxcnc-wasm-tooldata-link.sh;./test-native.sh;./test-linuxcnc-source-link.sh。
This commit is contained in:
@@ -272,6 +272,23 @@ int main() {
|
|||||||
if (tooldata_put(tool, 12) != IDX_NEW) {
|
if (tooldata_put(tool, 12) != IDX_NEW) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
CANON_TOOL_TABLE lower_index_tool = tooldata_entry_init();
|
||||||
|
lower_index_tool.toolno = 3;
|
||||||
|
lower_index_tool.pocketno = 5;
|
||||||
|
// LinuxCNC src/emc/tooldata/tooldata_mmap.cc returns IDX_OK for writes at
|
||||||
|
// or below the current last_index and leaves last_index unchanged.
|
||||||
|
if (tooldata_put(lower_index_tool, 5) != IDX_OK) {
|
||||||
|
return 80;
|
||||||
|
}
|
||||||
|
if (tooldata_last_index_get() != 12) {
|
||||||
|
return 81;
|
||||||
|
}
|
||||||
|
CANON_TOOL_TABLE lower_index_loaded = tooldata_entry_init();
|
||||||
|
if (tooldata_get(&lower_index_loaded, 5) != IDX_OK ||
|
||||||
|
lower_index_loaded.toolno != 3 ||
|
||||||
|
lower_index_loaded.pocketno != 5) {
|
||||||
|
return 82;
|
||||||
|
}
|
||||||
|
|
||||||
CANON_TOOL_TABLE loaded = tooldata_entry_init();
|
CANON_TOOL_TABLE loaded = tooldata_entry_init();
|
||||||
if (tooldata_get(&loaded, 12) != IDX_OK) {
|
if (tooldata_get(&loaded, 12) != IDX_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user