| zanshin | Are the rules because Linus wants them that way or are they based on something else? |
| jmgv | and class if you use c++ i suppose |
| snide | 13min too late ;-( |
| jmgv | although c++ is not used at kernel :-) |
| gcc | the proper way to break a too long line |
| riel_ | jmgv: the kernel is object oriented in places, for example the VFS |
| riel_ | jmgv: but as Alan said it very nicely, object orientation is in the mind, not in the compiler |
| jmgv | how mandatory are these rules. I mean,... if i send a patch to be include at kernel, and i use 4 space |
| tab instead 8 space ones, is it mean the patch could be back to me for that reason? |
| jmgv | riel_ okey i see |
| riel_ | jmgv: imagine a driver with 4 different programming styles in one .c file ;) |
| mulix | how about patches to clean up the coding style of old drivers? |
| mulix | are those a waste of time, or appreciated? |
| mulix | drivers/net/eepro100.c comes to mind... |
| jmgv | riel_ i see :-) it will be a curious kaos |
| snide | what about the unicity of the different function names all over the code ? is it a good thing, a bad |
| thing, a have-to ? |
| bh | uniqueness maybe? |
| snide | yes |
| snide | sorry about my english... |
| gregkh | no problem. |
| sarnold | so, how about typedef? :) |
| davej | (unless you're ingo) |
| gcc | why it so evil |
| viXard | umm, sorry |
| viXard | you meant evil? |
| boren | hey what about typedef for function pointer definitions? |
| gcc | got it |
| zanshin | what is bad about passing structures as parameters? |
| zanshin | the stacksize? |
| sarnold | zanshin: the kernel stack is only 8k... |
| snide | got disconnected sorry [ could someone be kind and msg me the reply -if there where any- ] |
| bh | you can pass a pointer to the structure, which saves memory, I think |
| zanshin | k thanks |
| sarnold | snide: 10:25 <@gregkh:#linux> yes, pick your function names well, and don't make them global unless |
| they have to be. |
| snide | sarnold: thx |
| gregkh | any other questions while the translation catches up? |
| riel_ | sorry about the little split |
| tiri | It doesn't matter |
| viXard | gregkh you can continue :-) |
| snide | btw, how to make a function "global" ? put in in a .h ? or EXPORT ? |
| cdub | snide: global within kernel...non static definition in a c file, and an extern in a .h is good enough. |
| snide | but what about #ifdef CONFIG_SMP inside mm/slab.c for exemple |
| cdub | EXPORT_SYMBOL is needed if you want modules to be able to use it |
| snide | oops, i'm getting quoted too much... |
| snide | ;-) |
| zanshin | is that the same as: struct foo = { |
| zanshin | read: func(), |
| zanshin | } |
| sarnold | zanshin, that is the GNU version... it is deprecated in favour of the new style.. |
| cdub | zanshin: yes |
| snide | how to avoid using #ifdef CONFIG_MYOPTION in a practical way then [ any exemple ? ] |
| zanshin | ah okay |
| zanshin | any reason for that... just curious. |
| sarnold | the newer format was standardized in C99.. why they didn't just take the GNU format, I have no idea. :) |
| cdub | zanshin: gcc deprepated the use. you get warnings with newer compilers |
| zanshin | I see |
| snide | so better split up the .c files ? |
| snide | so using a function that the content will be wiped out with an #ifdef ? |
| snide | gregkh: u should continue the talk, i don't want to hog u ;-) |
| gregkh | snide: that's it, I'm done unless there are more questions :) |
| snide | gregkh: ok ;-) so, i'll go through the URL and files that u pointed at |
| jmgv | one question |
| gregkh | sure. |
| jmgv | if i think i can contribute with some other rules i think can improve the code style or.... |
| snide | gregkh: thx a lot |
| jmgv | i think one of them can be changed, where i can send my arguments? |
| gregkh | jmgv: to the linux kernel mailing list, but be prepared to back them up :) |
| jmgv | :-) okey |
| sarnold | jmgv: you aren't going to convince them to switch to C++ :) |
| cdub | heh |
| snide | sarnold: maybe C# then ;-)) |
| jmgv | i am starting to be convinced to switch to C :-) |
| raciel | hehe, C# would be an option! :) |
| snide | sarnold: (in link with the Mono talk we had) |
| gcc | gregkh: just one more |
| gcc | > Some notes: |
| gcc | > - coding style: linux functions usually have only one return at the end |
| gcc | > of the function, and goto internally. |
| gcc | see this on the LKML |
| snide | jmgv: C is rather unfrienldy, but it does much less magic behind ur back than C++ ;-) and that's good |
| for an OS [ IHMO ] |
| gcc | saw |
| jmgv | snide: sure! |
| gregkh | gcc: ah, good point, I'll add that one to my list. It's a good thing to do. |
| snide | gcc: it's easier to track the exit point that way ;-) |
| gcc | snide: yeah, i allways use this, but always have some one saying that goto is lame |
| snide | although my C professor would jump if he sees a "goto" ;-) |
| raciel | gregkh: can you explain me what is data alignment and show me some example of that? |
| snide | gcc: goto is good if it help to follow a up-down algorithm path |
| gregkh | raciel: data alignment, like padding or packing data structures? |
| snide | gcc: quoted from Rusty's inline kernel docbooks |
| snide | ;-) |
| raciel | gregkh: packing data structures |
| snide | fernand0: will there be a bibliography web page on the web site ? |
| fernand0 | mmmm |
| fernand0 | there will be whichever the authors provide |
| fernand0 | of course, any links and references provided during the talk will be in the logs |
| snide | fernand0: sure, but i thought about a web page with all the links collected ;-) |
| gregkh | raciel: hold on, I have a good reference for that... |
| raciel | ok |
| fernand0 | colledcted or extracted ? |
| snide | fernand0: a page that one can bookmark ;-p |
| gregkh | raciel: see http://www.linuxjournal.com/article.php?sid=5783 for all about that. |
| snide | fernand0: extracted [ my english is poor ;-( ] |
| fernand0 | mine is also poor |
| snide | fernand0: seems better than mine ;-p |
| fernand0 | but i do not understand well |
| fernand0 | you are meaning a page with the links of this talk ? |
| snide | fernand0: u got the point ;-) |
| fernand0 | i don't think so |
| fernand0 | but it sounds as a good idea |
| twin | hola a todos |
| fernand0 | maybe we should think about it |
| FJx | gregkh, this is a little off-topic question but... can you recommend me any good begginer's book for |
| Programming in Linux? or just plain ANSI C? |
| fernand0 | it shouldn't be difficult to extract them |
| snide | fernand0: i know there isn't one here yet ;-) but i wondered if it is something that will appear ;-p |
| fernand0 | we'l try |
| snide | fernand0: i'll even do it if u want [ by hand, since it's not a HUGE task ;-p ] |
| gcc | well, got to work... |
| fernand0 | but just in case ... dowload the logs and grep http the_log.html |
| fernand0 | hehe |
| gcc | gregkh: thanks for the lecture... very nice.. |
| gregkh | gcc: no problem, was fun. you all were an easy audience :) |
| snide | gcc: yeah, the talks are of a really good quality ;-p |
| sarnold | http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_paper/codingstyle.ps |
| sarnold | http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ |
| sarnold | those are the two urls gregkh mentioned :) |
| snide | gregkh: execpt me ;-p [ ways too much questions ] |
| raciel | gregkh: other question, what technics do you use to debug your code? kdb? printk..? |
| sarnold | snide: i didn't think so... one nice feature of IRC conferences is that one can reach high levels of |
| interactions |
| gregkh | there's also other assorted ramblings that I've written lined off of http://www.kroah.com/linux/ |
| snide | sarnold: ow... another valuable URL ;-p |
| gregkh | raciel: printk mostly. haven't had to use a debugger yet, I do drivers, so debuggers don't help out |
| all that much at times with hardware. |
| snide | sarnold: yeah. it's the first IRC conf i'm doing, and it is wonderful ;-p |
| fernand0 | leaving |