X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=HACKING;h=aa408ffb6cad15c90ca5ecc0250475886b94a9e4;hp=9d71c55c11d0fa240b7eb3b5f32b83e0b20a095c;hb=HEAD;hpb=82b9f3d116ce0c982291a2dfdd15cd8a1c4cc16e diff --git a/HACKING b/HACKING index 9d71c55c..2d9abe95 100644 --- a/HACKING +++ b/HACKING @@ -79,6 +79,9 @@ Random notes - Generally avoid assigning values to variables at declaration time, especially so for complex and/or run-time dependent values. + - Separate assignments from control flow. Example: Avoid the pattern + if (var = func()) {...} as it complicates review and maintenance. + - Consistently use g_*malloc() / g_*malloc0(). Do not use standard malloc()/calloc() if it can be avoided (sometimes other libs such as libftdi can return malloc()'d memory, for example). @@ -95,6 +98,9 @@ Random notes Do use g_try_malloc() or g_try_malloc0() for large (>= 1MB) allocations and check the return value. + - Endianness conversion: Prefer the common helpers that are provided in + libsigrok-internal.h, such as read_u16be() etc. + - You should never print any messages (neither to stdout nor stderr nor elsewhere) "manually" via e.g. printf() or g_log() or similar functions. Only sr_err()/sr_warn()/sr_info()/sr_dbg()/sr_spew() should be used.