My first solution was the answer to the question how to write that
function without the use of goto.
I did that in less than 10 minutes and it's absolutely flawless, so yes
it's VERY EASY.
I posted the second solution only to show how I personally would prefer
to write that function
On Fri, 17 Jul 2015 10:48:53 +0200, Martin Knappe said:
> Very easy:
On Fri, 17 Jul 2015 11:40:00 +0200, Martin Knappe said:
> Like so:
On Fri, 17 Jul 2015 11:44:34 +0200, Martin Knappe said:
> Sorry, have to correct my solution. You need to add "cleanupState = 0"
> just before the "finish", like
mboards >= MAXBOARDS) {
rc = -EPERM;
goto finish;
}
rc = pci_enable_device(pdev);
if (rc) {
rc = -EIO;
goto finish;
}
brd = dgap_found_board(pdev, ent->driver_data, dgap_numboards);
if (IS_ERR(brd)) {
rc = PTR_ERR(
Like so:
static int dgap_init_one(struct pci_dev *pdev, const struct
pci_device_id *ent)
{
int rc = 0;
int cleanupState = 0;
struct board_t *brd;
if (dgap_numboards >= MAXBOARDS) {
rc = -EPERM;
goto finish;
}
rc = pci_enable_device(pdev);
I'm just messing ...
I guess I felt a bit challenged by your "try to write that without using
goto"
I use goto myself very much for function cleanup. I wouldn't normally
code the way I did in that snippet.
Apart from that, my general rule for any function is:
1) Only ONE
= BD_RUNNING;
dgap_board[dgap_numboards++] = brd;
return 0;
}
Am 17.07.2015 10:11 schrieb Sudip Mukherjee:
> On Fri, Jul 17, 2015 at 1:25 PM, Navy wrote:
>> Hello,
>> Goto is recommend in linux kernel programming, but it is despised in
>> many other sit
On 17 July 2015 at 11:00, Bernd Petrovitsch
wrote:
> Hi!
>
> On Fre, 2015-07-17 at 15:55 +0800, Navy wrote:
> [...]
> > Goto is recommend in linux kernel programming, but it is despised in
> > many other situation. There are four rationable for using goto in
>
&
Hi!
On Fre, 2015-07-17 at 15:55 +0800, Navy wrote:
[...]
> Goto is recommend in linux kernel programming, but it is despised in
> many other situation. There are four rationable for using goto in
"goto" is (usually totally) forbidden for beginners/inexperienced
programmers be
On Fri, Jul 17, 2015 at 2:52 PM, Martin Knappe
wrote:
> I'm just messing ...
> I guess I felt a bit challenged by your "try to write that without using
> goto"
Hey, it was not a challenge. main thing is the readability.
But going by your general rules how will you modi
On Fri, Jul 17, 2015 at 2:18 PM, Martin Knappe
wrote:
> Very easy:
Looks good. :)
But for me, now while reading the code I have to keep a note of the
value of cleanupState variable and the error path becomes confusing.
And besides in your opinion now which code is more readable, the original
code
On Fri, Jul 17, 2015 at 8:55 AM, Navy wrote:
> Hello,
> Goto is recommend in linux kernel programming, but it is despised in many
> other situation. There are four rationable for using goto in
> Documentation/CodingStyle. Do you have some viewpoints about "why goto" or
>
On Fri, Jul 17, 2015 at 1:25 PM, Navy wrote:
> Hello,
> Goto is recommend in linux kernel programming, but it is despised in many
> other situation. There are four rationable for using goto in
> Documentation/CodingStyle. Do you have some viewpoints about "why goto" or
Hello,
Goto is recommend in linux kernel programming, but it is despised in many other
situation. There are four rationable for using goto in
Documentation/CodingStyle. Do you have some viewpoints about "why goto" or "why
not goto"? I'm glad to
13 matches
Mail list logo