Sponsored Content
Operating Systems Linux Ubuntu Use of goto keyword in kernel programming Post 302967974 by BHASKAR JUPUDI on Tuesday 1st of March 2016 10:36:42 PM
Old 03-01-2016
Use of goto keyword in kernel programming

I have found many source files in the kernel using goto keyword instead of just doing the actual thing. For example:

Code:
if(blah)
goto x;
--
--
--
--
--

x: return blah-blah

Is there any specific reason for writing the code like this? The first thought that came to my mind is minimizing code duplication. If we are going to change the
Code:
return (blah-blah)

then with the use of goto we have to change only one instance of it. I'm asking this because if we consider the above situation, if we replace
Code:
goto x

with
Code:
return blah-blah

(to avoid the overhead of calling goto) then will that be a patch?
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Kernel and Device Driver Programming

I am looking for a guide on how to program for either the Linux or FreeBSD (includes 4.4BSD, NetBSD or OpenBSD) kernel. I would prefer to learn how to write device drivers, but anything would help. If you know, please email me at *removed* or leave a post here Regards, Farhan (0 Replies)
Discussion started by: Farhan
0 Replies

2. Programming

To study kernel and modular programming

I want to do kernel programming.So which site or books help me in studying these.I know C programming to a little extent.Please advice me (4 Replies)
Discussion started by: ranjith
4 Replies

3. Linux

Kernel programming: packet divertion

Hi All, Not sure if this is the right place to ask, so please tell me where is appropriate... Anyway, here is the problem. I'm a bit new to kernel programming, so nothing works :confused: . I need to intercept cetrtain ethernet packets from Host1("eth0") to Host2("eth1") and send them to... (1 Reply)
Discussion started by: sl_king
1 Replies

4. Linux

kernel programming

:) Hi, I intend to learn kernel programming. Please, let me know if have know any good books for learning or any sites which will be help me. Thanks in advance. - masg (1 Reply)
Discussion started by: masg1
1 Replies

5. UNIX for Advanced & Expert Users

Passing socket struct between kernel threads - module programming

I write kernel module with kernel threads using linux/kthread.h on 2.6.* kernel I tried to passing data between two kernel threads with data argument of kthread_run( fun, data , NAME ); but this is not work I dont know why. I tried many possibility and nothing works. So I thought that... (0 Replies)
Discussion started by: marcintom
0 Replies

6. UNIX for Advanced & Expert Users

Kernel Programming: Finding the number of I/O requests

Hi I'd like to know a logic or a strategy to count the number of I/O requests that are being made. I have the PID of the process for which this needed to be done. Does anyone have any clue as to how to do this? This is to be done in Kernel programming in C. P.S: This is to be done in... (2 Replies)
Discussion started by: Ir1s
2 Replies

7. Fedora

Newbie at Linux Kernel programming!

Hi Friends, This is my first ever post on this forum. I am a new user in the Linux field. Although, I have been working for sometime with CentOS at my work, I would consider myself an amateur only in this field. :D The way file system works in linux and the reason its open-source, has really... (7 Replies)
Discussion started by: rohitrajjain
7 Replies

8. Programming

Kernel programming - Ext4 and extents contents

Hi there, I have a problem with Unix kernel programming. I have to write a program who should output the whole information the EXT4 extents contain. I have found many tutorial and information about how the EXT4 filesystem is working. Also There ar many information about the EXT4 structure but I... (1 Reply)
Discussion started by: oedurgan
1 Replies

9. UNIX for Advanced & Expert Users

Kernel programming sys_creat

Hi there At first. My Name is Andre, 27 and im from germany Im tryin to learn something about the Unix Kernel and System At first im trying to manipulate the systemcalls I want to have an Entry in the kernel logfile, whenever a new file is created. I found out, that a file uses the... (0 Replies)
Discussion started by: kissthechief
0 Replies

10. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies
explain_select_or_die(3)				     Library Functions Manual					  explain_select_or_die(3)

NAME
explain_select_or_die - blah blah and report errors SYNOPSIS
#include <libexplain/select.h> void explain_select_or_die(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); DESCRIPTION
The explain_select_or_die function is used to call the select(2) system call. On failure an explanation will be printed to stderr, obtained from explain_select(3), and then the process terminates by calling exit(EXIT_FAILURE). This function is intended to be used in a fashion similar to the following example: explain_select_or_die(nfds, readfds, writefds, exceptfds, timeout); nfds The nfds, exactly as to be passed to the select(2) system call. readfds The readfds, exactly as to be passed to the select(2) system call. writefds The writefds, exactly as to be passed to the select(2) system call. exceptfds The exceptfds, exactly as to be passed to the select(2) system call. timeout The timeout, exactly as to be passed to the select(2) system call. Returns: This function only returns on success. On failure, prints an explanation and exits. SEE ALSO
select(2) blah blah explain_select(3) explain select(2) errors exit(2) terminate the calling process COPYRIGHT
libexplain version 0.52 Copyright (C) 2008 Peter Miller explain_select_or_die(3)
All times are GMT -4. The time now is 04:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy