programmingadv.blogspot.com
Coding Misadventures: November 2012
http://programmingadv.blogspot.com/2012_11_01_archive.html
What not to do in C programming. Monday, November 26, 2012. And that's the way it is! One of the errors reported by Coverity on our code was this:. Logical vs. bitwise operator (CONSTANT EXPRESSION RESULT). Sense is always 1/true regardless of the values of its operand. This occurs as the bool operand of assignment. Did you intend to use '! Rather than ' '. The code it referred to was something like:. Note: If we write:. Bool result = sense;. Instead, we get the same result and same error. View my comple...
programmingadv.blogspot.com
Coding Misadventures: Identity Crisis
http://programmingadv.blogspot.com/2007/10/identity-crisis.html
What not to do in C programming. Wednesday, October 3, 2007. Early this week, I got crashes in many testcases, on 64-bit mode, and only on Linux platforms (Solaris was fine in both 32- and 64-bit modes). Debugging such issues is a big problem, because they are almost certainly tricky memory corruptions, and debugging in 64-bit environment is seriously hampered by unavailability of proper support in debugging tools. 1) Reproduce the crash in an environment, where it is easier to debug. This did not help.
programmingadv.blogspot.com
Coding Misadventures: My 64-bit porting experiences -V
http://programmingadv.blogspot.com/2007/06/my-64-bit-porting-experieinces-v.html
What not to do in C programming. Sunday, June 17, 2007. My 64-bit porting experiences -V. 5 Use of compatible, but incorrect datatypes. An API function, ‘func1’ returns int*, which actually points to an array of two integers. The part of code that uses this function is as follows:. Long *lp = func1(…);. Int lval = lp[0];. Int rval = lp[1];. The results were correct in 32-bit, because int. Are same size. On 64-bit, the return values were incorrect, because of the difference in size of int. BTW I have crea...
programmingadv.blogspot.com
Coding Misadventures: My 64-bit porting experiences - II
http://programmingadv.blogspot.com/2007/04/my-64-bit-porting-experiences-ii.html
What not to do in C programming. Friday, April 27, 2007. My 64-bit porting experiences - II. 2 Assumptions on size of predefined datatypes. Ideally, any implementation should not place an assumption on the size of pre-defined datatypes, because these sizes are not standard, and are usually at the discretion of OS implementation provided some boundary conditions are satisfied (e.g., an int. Shall at least be 16 bits). Most of the code that I was porting, was based on the premise that int. My porting exper...
programmingadv.blogspot.com
Coding Misadventures: November 2007
http://programmingadv.blogspot.com/2007_11_01_archive.html
What not to do in C programming. Thursday, November 1, 2007. On my previous post, I was asked if there was any specific reason to get the 20 year old program compiled on the latest compiler? It should be expected that the older executable would continue to run even on new versions of the OS. Here is the answer. There are many reasons for porting:. In our case, we moved from gcc 3.2.3 to gcc4.1.1 company-wide, for Linux platforms. Subscribe to: Posts (Atom). View my complete profile. A Geeky Sense of Humor.
programmingadv.blogspot.com
Coding Misadventures: October 2007
http://programmingadv.blogspot.com/2007_10_01_archive.html
What not to do in C programming. Wednesday, October 31, 2007. Venturing Into Unchartered Territory. By default, the C compilers place string constants and (other constant data) into protected memory (read-only section), where they cannot be modified during the runtime. Here is a small program to illustrate the problem:. Static char * keys [] =. Abc", "def", "ghi", "jkl" };. Int my sm hash(char *strup). Int modified = 0;. Char ch = ' 0';. While ( ch = *strup)! Strup = toupper(ch);. Modified = 1;. In the s...
programmingadv.blogspot.com
Coding Misadventures: June 2007
http://programmingadv.blogspot.com/2007_06_01_archive.html
What not to do in C programming. Wednesday, June 27, 2007. My 64-bit porting experiences - VI. We have always been instructed to reuse code, as it makes the code more maintainable. But it can sometimes be taken too far (too much of a good thing? 61 Objects of different sizes in a union. Int getVal {return bVal;}. Exp *getExpr {return bExpr;}. Int hasExpr {return isExpr;}. In the following piece of code , ‘obj a’ is an object of class ‘A’:. Int tmp = 0;. Exp *tmpExpr = NULL;. Tmp = obj a- getVal();. And p...
programmingadv.blogspot.com
Coding Misadventures: My 64-bit porting experiences - I
http://programmingadv.blogspot.com/2007/04/64-bit-saga-continues-i.html
What not to do in C programming. Tuesday, April 17, 2007. My 64-bit porting experiences - I. Following code examples functioned harmlessly while the code was compiled and run on 32-bit, but crashed on 64-bit. Many of them could have been avoided, if compiler and/or lint warnings were attended to. Char *str = (char *)malloc(n * sizeof(char) ;. The standard library that provides the definition of ‘malloc’. Ptr = func ret ptr(…);. Declaration incorrectly declared the return type of the function to be int.
programmingadv.blogspot.com
Coding Misadventures: Venturing Into Unchartered Territory
http://programmingadv.blogspot.com/2007/10/venturing-into-unchartered-territory_31.html
What not to do in C programming. Wednesday, October 31, 2007. Venturing Into Unchartered Territory. By default, the C compilers place string constants and (other constant data) into protected memory (read-only section), where they cannot be modified during the runtime. Here is a small program to illustrate the problem:. Static char * keys [] =. Abc", "def", "ghi", "jkl" };. Int my sm hash(char *strup). Int modified = 0;. Char ch = ' 0';. While ( ch = *strup)! Strup = toupper(ch);. Modified = 1;. In the s...