libvmz: return immediate status from async operations #29

Open
opened 2026-05-22 10:38:05 +00:00 by rc · 0 comments
Owner

Problem:

  • Asynchronous functions return void.
  • vmz_start and vmz_force_stop cannot synchronously report immediate misuse such as NULL handle, NULL callback, invalid state, or failed scheduling.

Why this is bad:

  • Immediate API misuse and eventual operation failure are different categories.
  • Returning void pushes every problem into callbacks or undefined behavior.
  • C callers expect a fast status return for argument/state validation.

Suggested fix:

  • Make async operations return VMZStatus immediately.
  • Use the callback only for eventual operation completion.
  • Validate handle, callback, and VM state before starting async work.

Relevant code:

  • lib/libvmz.h: vmz_start and vmz_force_stop return void.
  • lib/libvmz.swift: functions directly dereference opaque handles and invoke async framework calls.
Problem: - Asynchronous functions return void. - vmz_start and vmz_force_stop cannot synchronously report immediate misuse such as NULL handle, NULL callback, invalid state, or failed scheduling. Why this is bad: - Immediate API misuse and eventual operation failure are different categories. - Returning void pushes every problem into callbacks or undefined behavior. - C callers expect a fast status return for argument/state validation. Suggested fix: - Make async operations return VMZStatus immediately. - Use the callback only for eventual operation completion. - Validate handle, callback, and VM state before starting async work. Relevant code: - lib/libvmz.h: vmz_start and vmz_force_stop return void. - lib/libvmz.swift: functions directly dereference opaque handles and invoke async framework calls.
Sign in to join this conversation.
No labels
highprio
lowprio
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rc/vmz#29
No description provided.