public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [Question] Dead code in KVM PIT ioctl error handling?
@ 2026-01-31 16:30 Ingyu Jang
  2026-02-03  0:44 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: Ingyu Jang @ 2026-01-31 16:30 UTC (permalink / raw)
  To: kvm; +Cc: seanjc, pbonzini, Ingyu Jang

Hi,

I noticed that in arch/x86/kvm/x86.c, the functions
kvm_vm_ioctl_get_pit() and kvm_vm_ioctl_get_pit2() always return 0,
making their error checks unreachable.

Both functions (at lines 6408 and 6433) simply perform:
  1. Lock mutex
  2. Copy PIT state
  3. Unlock mutex
  4. return 0;

There are no error paths in either function.

However, their call sites check the return values:

1. At line 7164:
   r = kvm_vm_ioctl_get_pit(kvm, &u.ps);
   if (r)
       goto out;

2. At line 7190:
   r = kvm_vm_ioctl_get_pit2(kvm, &u.ps2);
   if (r)
       goto out;

Since both functions always return 0, these error checks appear to be
dead code.

Is this intentional defensive coding for potential future changes,
or could this be cleaned up?

Thanks,
Ingyu Jang

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-03  0:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 16:30 [Question] Dead code in KVM PIT ioctl error handling? Ingyu Jang
2026-02-03  0:44 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox