Wednesday, 26 March 2014
Losing the plot?
This is code I used to be able to do in a few hours, and, ironically, have done in a few hours for almost identical code many years ago. I am only re-writing because it needs to be more maintainable and more modular and used in a different environment.
But it has not been as fun as it should be, and I even gave up on one bit and gave it to Cliff to play with. That is so unlike me.
I spent over an hour today chasing the fact I used gettimeofday(&tv) by mistake instead of gettimeofday(&tv,NULL) and left the include out that would have warned on the mismatched prototype. Stupid arse mistake if ever I made one.
The issue being the 2nd arg was random stack content as a pointer to which to write the timezone, and that corrupted the stack and crashed the forked process. Every minor change, just adding or removing printfs for debug changed it from not working to working or back again. And even valgrind, my friend in times of need, let me down.
I must be losing it.
Anyway, I'll sleep on it, and tackle the problem again tomorrow. Hopefully Cliff will have sorted some simple alaw V.23 demod for me. It is not hard, and seriously I have done this many times before, but I could just not get it to work.
With any luck, in a few days, I'll be able to blog on how wonderful this little bit of code is, but right now I feel like I am getting passed it.
P.S. Thanks for all of the "helpful" comments about use of -Wall. Obviously, after 35 years of coding, I did not know about compiler warnings, d'uh. This is, indeed, something that is normally set for everything we are doing, and the lack of it in the Makefile in question was, perhaps, the first mistake. I am used to it being set, and is on most of the Makefiles we have. The lack of such warnings, which I am used to being given by the compiler, made it that bit harder to spot the stupid mistake. I have instigated a bit of a witch hunt for any code being compiled without -Wall now though.