Profile cover photo
Profile photo
Antti Palosaari
355 followers -
Oulu
Oulu

355 followers
About
Posts

Post has attachment
Photo
Add a comment...

Post has shared content
Good tips for proper error handling of Linux kernel (suitable for almost all C coding cases as well). #kerneldevelopment #errorhandling
I spend lots of time looking at linux kernel error handling.  For example, if you run this command in the kernel git repository:

`git log --grep error --after=2010 --no-merges | grep ^Author | sort | uniq -c | sort -rn | cat -n | head -n 5`

     1      405 Author: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
     2      277 Author: Dan Carpenter <dan.carpenter@oracle.com>
     3      235 Author: Sachin Kamat <sachin.kamat@linaro.org>
     4      216 Author: Dan Carpenter <error27@gmail.com>
     5      197 Author: Arnd Bergmann <arnd@arndb.de>

Hooray!  I'm number 2 and number 4 at using the word "error" in my git commit messages!  Here are is my rant on how to do error handling correctly.

***MOST IMPORTANT!  Do not do "one err" style error handling.  It looks like this:

err:
        kfree(foo->bar);
        kfree(foo);
        return ret;

The "one err bug" here is that "foo" is sometimes NULL.  The problem is that when you merge all the error handling paths into one path then it becomes a confusing mess.  This is the most common kind of bug that I fix.

***Choose good label names.  The label name should say what the goto does.  It's normally based on the line right after the label.

err_free_bar:
        kfree(foo->bar);
err_free_foo:
        kfree(foo);
        return ret;

Don't use GW-BASIC style names "err1" and "err2".

Don't name it after the goto location.  That looks like:

    foo = kmalloc();
    if (!foo) goto kmalloc_failed;

We can already see that kmalloc() failed from the context and, inevitably, the next line is going to be "if (type == ISA) goto kmalloc_failed;" which is so bogus.

Bad label names are a pain because you see the goto first and it doesn't tell you anything so you have to scroll down to the bottom of the function.  Now you've lost your place and your train of thought and so you have to start over.

***Don't use do-nothing gotos like "err: return -ENOMEM;".  Just return directly.  Putting error handling stubs might seem like defensive coding, but stubs are against linux kernel style and we don't do defensive programming.  http://lwn.net/Articles/604813/

***Do "error handling" not "success handling".

GOOD: foo = kmalloc();
      if (!foo) {

BAD:  foo = kmalloc();
      if (foo) {

Success handling leads to spaghetti code.

***Keep the error path and the success path separate.  This is a hint not a rule.  "return ret;" and "return 0;" might mean the same thing but "return 0;" is more clear.

***out: label considered harmful.  If you see an out label then it could be a do-nothing stub or it could be one err style error handling or it could be valid error handling but the naming is crap.
Add a comment...

Post has shared content
So, I made noises some time ago about how I don't want another 2.6.39 where the numbers are big enough that you can't really distinguish them.

We're slowly getting up there again, with 3.20 being imminent, and I'm once more close to running out of fingers and toes.

I was making noises about just moving to 4.0 some time ago. But let's see what people think.

So - continue with v3.20, because bigger numbers are sexy, or just move to v4.0 and reset the numbers to something smaller?
-
votes visible to Public
43%
I like big versions, and I cannot lie
57%
v4.0, 'cause I get confused easily
Add a comment...

Post has attachment
Linux media patches for kernel 3.20! #LinuxTV #LinuxMedia #KernelDevelopment #Linux  
Add a comment...

Post has shared content
Sony has released new DTV demodulator and RF tuner combo chip called SMT-EW100. It supports now DVB-T2 Lite profile for mobility transmission (mobile TV and radio). That chip is clearly aimed for mobile terminals as there is no support for cable television - hopefully it is added later. #DVBT #DVBT2Lite #ISDBT #ISDBTmm   #SMTEW100 #Sony
Sony launches new mobile one chip DVB-T2 | T2 Lite digital radio & TV Tuner module with very low power consumption - under 200 mW.

Sony has announced the launch of its new digital radio & TV tuner Module designed for mobile devices such as smartphones, tablets, automotive infotainment systems, navigation systems and PCs.

The DTT tuner module boasts the world's smallest size and superior reception as well as extremely low power consumption, making it an optimal candidate for inclusion into mobile devices.

The SMT-EW100 series is the DVB-T2 compatible module, especially designed to be incorporated in the mobile devices and is the first module from Sony specialized for mobile usage.

The tuner module supports various types of digital terrestrial digital radio & TV broadcast systems, including DVB-T, DVB-T2, DVB-T2 Lite, ISDB-T and ISDB-Tmm including the 1.7 MHz BW in VHF band III as an alternative to DAB/DAB+/ DMB.

SMT-EW100 series tuner module, comes as part of a total solution package that includes the module, antenna, software, and technical support.

Provided with this total solution package, manufacturers of mobile devices will be able to easily incorporate a digital radio and TV feature into their products.

The shipment of SMT-EW100 will start in May 2015.

Key Features of the SMT-EW100 Series
Dimensions: 6.9 mm x 6.9 mm x 1.0 mm (incl. Filter, Crystal)
Supports DVB-T, DVB-T2, DVB-T2 Lite, ISDB-T, ISDB-Tmm
Low power consumption: under 200 mW
Multi-Interface Data: TS, SPI, SDIO              
Control: I2C, SPI, SDIO
Comes as part of a total solution package that includes the module, antenna, software, and technical support
Supplied together with the Android driver package

#DVBT2   #T2LITE   #Digitalradio  
Photo
Photo
2015-01-24
2 Photos - View album
Add a comment...

Post has attachment

Post has attachment
Photo
Add a comment...

Post has shared content
Comprehensive overview of DVB-T2 Lite digital radio by +Kenneth Wenzel 
Add a comment...

Post has attachment
I added Linux support for upcoming Hauppauge WinTV-HVR5525! #Hauppauge #HVR5525 #linuxtv #linuxmedia #DVBT2 #DVBS2  
Add a comment...

Post has attachment
Wait while more posts are being loaded