Monthly Archives: October 2007

What’s Wrong with this Code 2

We’ve been working on our next version of our flagship product at work and, as part of that, we upgraded to Visual C++ 8 (2005) and turned on the most strict compiler settings, warning level 4, more debug runtime checks–basically trying to make everything very strict.

As part of that process, we had to go through the code and fix hundreds (thousands?) of warnings that just became errors.

One area was the following:

                 for(i = 0; i < overlaySize.cx; i++) {
                    long i1 = (long)((double)i / numXTimes);
                    double xPercent = (double)i / numXTimes - i1;

                    // get the indeces into the data array
                    long lIndex1 = i1 + (j1 * m_DataSize.cx);
                    long lIndex2 = lIndex1 + m_DataSize.cx;

                    double yVal1, yVal2;
                    if(i1 != oldi1) {
                        yVal1 = m_DataArray[lIndex1] + //etc...

yVal2 = m_DataArray[lIndex1 + 1] + //etc...
                        oldi1 = i1;
                    }

                    // figure out the value
                    double theVal = yVal1 + (yVal2 - yVal1) * xPercent;
                }

I’ve of course cut out a number of lines from this loop that weren’t relevant to the point.

The compiler flagged yVal1 and yVal2 as being potentially unitialized before they were used. It’s because they’re initialized inside an if statement.

So to remedy this, I initialized them to 0.0:

double yVal1=0.0, yVal2=0.0;
if(i1 != oldi1) {

//etc.

I go on to fix other warnings-become-errors, and we finally create our first build with VC8 a week or two later. Then, we start having problems in one area of the program. A data file is working on looks horrible, and it’s taking 45 minutes to do the calculations instead of 2-3 seconds. What’s going on? It took a while to find it, but find it I did…

There is a serious bug in the code above, which my initializing the variables hid. The answer next time!

Washington, DC / Baltimore photographer

Thibeaux Lincecum contributed to my Buy Me a Lego campaign and deserves some props. He’s a photographer local to Washington, DC / Baltimore and I enjoyed many of his photos. He’s got a lot of stuff with Burning Man, weddings, parties, and a ton of others. I liked the Montgomery County Fair photos, particularly this one. Very nice. So go check out his stuff.

Technorati Tags: , , , , ,

Shout out to a store at Bricklink

I buy most of my Legos these days second-hand from a huge online market called BrickLink. People post their inventories for sale, and you can order from all of these people. BrickLink manages all of it.

Well, one store (so far) is a generous donor in the Buy Me a Lego campaign, and I wish to mention them specifically.

Front Range Lego, has chipped in with a great donation of $5.00.

Not an insignificant donations. If you need to get some Lego bricks on the cheap, go check them out.

Technorati Tags: , , ,

Announcing Buy Me a Lego

So I’ve resorted to desperate measures. 🙂

I’ve started a small experiment/campaign to raise the cash for a Lego Millenium Falcon. But I am making it worth people’s while. Whoever donates gets a link from the page to their own site.

The way it works is:

* for 65 cents, I put a link to their blog on the site.

* for $2 I ALSO mention them on this blog.

* for $10 I will put up a banner ad.

Will it work? I think so. Links to sites are worth it. It can help boost traffic. This blog isn’t super-popular, but it’s growing larger and has quite a bit of traffic every day. I think the site I just setup will get dugg or slashdotted one of these days.

So head over to http://www.BuyMeALego.com and contribute! Thanks!

 

Watkins Apothecary

I just wanted to say thank you to Valerie and Don for their contribution to my Buy Me a Lego campaign. Their generous donation deserves a link to the web-site of a very interesting store. As an aspiring gourmet, I particularly enjoy the pantry section of the store. I’ve been meaning to look into some high-quality spice and herb sources on the Internet, since what we can find around here in DC is sadly lacking in quality.

My grandfather would have loved this store. He was an excellent amateur chef and had a nice collection of spices, oils, and other ingredients that came from stores like this.

Technorati Tags: , , , ,