Re: GlusterFS warning fixes!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Sep 09, 2006 at 12:26:01PM -0700, Amar S. Tumballi wrote:
,----
| Harsha,
| Thanks. I applied those changes and removed other warnings too. Btw,
|   now on start working on other archive 'gluster--fs--1.0'
`----
We have already moved to gluster--fs--2.0. Please port your changes to
2.0 branch. I should find a way to freeze commits to 1.0 branch.

Before we add any more new features, we should take care of the
following:
* All input arguments should be checked for validity
* Always try avoiding void return types. Return -1 for error and 0
for success with appropriate errno setting. For pointer return types,
return NULL for error.
* Invalid input args should have EINVAL errno.
* When ever you return with error, logging with gf_log is must.
* All global functions and variables should be prefixed with gf_ or
declared static otherwise. Otherwise we are polluting the name
space. This is not only important in libraries, but also general
code. Because external libraries may clash with our names.
* Use gcc-4.1 and treat all warnings as errors.
* Use format macros from stdint.h to ensure portability between 32bit
and 64bit platforms.
* Try avoiding functions returning allocated buffer. Instead take a
pointer to pre-allocated buffer. You can introduce functions that
calculates buffer length. This way, we can use alloca in place of
malloc.
* All dynamically allocated memory pointers should be followed by
length variable in all function arguments. And you should check for
appropriate size before you use the buffer. Otherwise it may lead to
memory corruption. Use snprintf in place of sprintf and alike calls.
Use memcpy or strncpy in place of strcpy.
* dict should have iteration function. dict is more effective than
linked list in many of our cases. 
*  Write comments if your code is not readable enough.
* Avoid global variables and take them as part of function
arguments. If there are lot of such states, group them under a struct.
* It is better to have readable long names than short cryptic acronyms
in naming variables and functions. 
* As a convention, always arrange input arguments before output
arguments in functions.  

You can also find the same under
http://gluster.org/docs/index.php/GlusterFS_Hackers_Guide#Coding_Guidelines


-- 
Anand Babu 
GPG Key ID: 0x62E15A31
Blog [http://ab.freeshell.org]              
The GNU Operating System [http://www.gnu.org]  

Z RESEARCH [http://www.zresearch.com] 
A Supercomputing Company.





[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux