Re: Try/catch for modules?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18/10/2019 17:43, Martin Galvan wrote:> El jue., 17 oct. 2019 a las 19:13, Valdis Klētnieks
> (<valdis.kletnieks@xxxxxx>) escribió:
>>
>> For starters, the *correct* in-kernel way to deal with this is:
>>         if (!ptr) {
>>                 printk("You blew it!\n");
>>                 goto you_blew_it;
>>         }
> 
> goto statements are harmful. In any case, what I meant was to have
> some sort of safety net to prevent exceptions (i.e. if I screw up and
You actually want speed in the kernel and not necessarily extra effort
for "try" and "catch" which is - sooner or later - never really used.
And the "safety net" reduces the motivation to actually fix pointer bugs ....

> forget a NULL check) from panicking the system.
> 
>> Also, "current PID" and "my module" aren't two things that can correspond....
> 
> I don't understand what you mean by that. Module code (e.g. an ioctl)
> runs as some process. In the case of an ioctl, I'd assume it's the
A ioctl-handler runs in the context/on behalf/... of a process
(read: a user-space process/thread has called a syscall).

> same PID of the user process.
And there may be other code in your module which doesn't run
on behalf of a process/thread, e.g. triggered by a timer, hardware
IRQ, ...

So in general you don't have a "process" or "thread", only in some
situations....

MfG,
	Bernd
-- 
"I dislike type abstraction if it has no real reason. And saving
on typing is not a good reason - if your typing speed is the main
issue when you're coding, you're doing something seriously wrong."
    - Linus Torvalds

Attachment: pEpkey.asc
Description: application/pgp-keys

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux