LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 03-25-2021, 10:15 AM   #1
BYPARK
LQ Newbie
 
Registered: Mar 2021
Posts: 2

Rep: Reputation: Disabled
Red face Why don't we use success status macro in kernel?


Hi, all.
It's my first question in here and I'm newbie in kernel development.
I was curious when I saw that error codes are defined in macros
while success status is not expressed by macros.

For example, error codes are expressed by macros like this.
Code:
return -EINVAL;
However, success is not defined but expressed by constant number.
Code:
return 0;
Why don't we use a macro for success status for unity with fail status (error code)?
(I think that one of possible reasons are clarity of constant number (0)
or that success status is not always expressed by 0)

I tried to use similar macros such as SUCCESS or NO_ERROR,
but it seems that they are not defined in official mainline codes.
 
Old 03-26-2021, 05:01 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,038

Rep: Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346Reputation: 7346
by default the return value 0 means ok. That is a general rule. So you can say this is an exception, there is no real need (to use a macro).
 
Old 04-03-2021, 09:43 AM   #3
BYPARK
LQ Newbie
 
Registered: Mar 2021
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thumbs up General Rule

Thank you for the answer.
So it seems that using 'return 0;' is a general and traditional method, which make its meaning clear.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why won't this macro work in a simple comparison if(rx(n)>n1) but in these other cases? DeeDeeK Programming 9 02-11-2017 07:55 PM
#defining a macro inside a macro? saravkrish Programming 1 05-24-2005 09:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration