Loud ramblings of a Software Artisan

Sunday 28 August 2011

I hate hardware

My Linux server rebooted spontaneously and then decided to kernel panic.

Running memtest off a bootable Gnome 3 Live USB system:

Diagnosis: dead RAM stick. With only one stick, memtest even crash on test 6, while the other just pass.

The good news is that the motherboard support single channel. The second good news is that it is lifetime warranty. Requested a RMA.

The bad news: I might have to return both as they are paired leading to eventually a longer downtime. :-/

A case for braces

I am one of those who believe C and C++ should have made curly braces mandatory.

Recent version of gcc and other compiler emit a warning when you have the following:

if(foo)
  ;

It does it because you could do something like

if(foo);
{
  // do something for foo
}

And this is likely a bug. But imagine the following case:

if(foo)
  DEBUG_MESSAGE("foo");

Now you have DEBUG_MESSAGE() defined as a macro that is empty in non-debug (you don't want these for your users). Then you end up with the warning for the situation above when doing your builds. There would be no problem had you written it this way:

if(foo)
{
  DEBUG_MESSAGE("foo");
}

Also another case:

if(foo)
  if(bar)
    do_bar();
else
  dont_foo();

Do you see the bug? That's right, the code is wrong: dont_foo() is executed in the else case for if(bar). Had you put curly braces it would have been clearer of what is happening. Like that:

if(foo)
{
  if(bar)
  {
    do_bar();
  }
}
else
{
  dont_foo();
}

Also if you find this a bit too hard because of the many like, can write with that style of bracing:

if(foo) {
  if(bar) {
    do_bar();
  }
}
else {
  dont_foo();
}

The opening brace at the end of the opening statement.

Another case:

if(obj)
  obj->data->foo = 1;

Now you know that data can not be null and want to catch it when testing. So you add one line:

if(obj)
  DEBUG_ASSERT_NOT_NUUL(obj->data);
  obj->data->foo = 1;

Oops. Did you realize this is wrong? Mistakes happen. Mistakes can be prevented. Curly braces would have prevented it.

Note: in the code above you should still ensure that obj->data is not NULL before dereferencing, but that's a different subject, for another time.

Bottom line, don't be lazy. Make the use a curly braces mandatory in your coding style. If your compiler has a warning for that, enable it.

Saturday 27 August 2011

Picnurbia

Part of the 125th anniversary festivities, Picnurbia at the just finished 800-block of Robson Street for Viva Vancouver.

Vancouver, BC - August 16th 2011

Flickr - 500px

Thursday 18 August 2011

Dear Google,

Dear Google,

Who are you to tell me how I should write my name?

You could have managed than one swiftly. You didn't. You got feedback, you answered with worse policy. Your policy is so bad that it won't even be enforceable fairly, as you still have you own employees with fake profile, or exempt celebrities.

You created some great product and in that case you f***ed it up real hard.

You disable my profile, goodbye[1].

PS: Get a clue: read My name is me

PPS: even people using their real names get rejected - language warning over there.

Notes

[1] as of now I'm still on notice. Not changing it

Sunday 14 August 2011

The dog whisperer

If you bring a toy that sqweek at the Boston Terrier meetup, you are sure to get a herd of these little daemons. Hadden Park, Kitsilano, Vancouver, BC - July 18th 2010

Monday 8 August 2011

Censorship?

Yesterday, I sent an email to Shoppers Drug Mart, a large pharmacy retail chain here in Canada. My complain was solely that they sell cigarettes (in British Columbia). Yes you read it right a pharmacy sell cigarettes. Does that shock you? It does shock me.

I was expecting either no reply at all, or some boiler plate reply, but I think they really exceeded my expectations in term of BullC.

Here is the reply, verbatim:

Hello Hubert,

Thank you for writing to us. The entire philosophy of our company is based on the understanding of care and concern for all of our customers. Our promise is to provide superior customer satisfaction beyond expectation. Shoppers Drug Mart receives a tremendous amount of advice from a wide spectrum of advocates, each with their own value systems, about the many products that a drug store sells. Their assumption is that consumers need to be protected from themselves. Shoppers Drug Mart's position is that it will not allow itself to become the cultural or moral censor for any legal product. The fact that we sell a product does not constitute any endorsement on our part of that product.

One of the great underlying perils of merchandising and retailing, regardless of diligent testing for possible hidden, offensive, or unintended messages, it may be interpreted that a product is unsuitable for the general public. To refuse to sell a product that one takes issue with would clearly be a form of censorship on our part which is a position we will not take.

Tobacco is typically displayed behind the counter, so it is not accessible to children. We hope that you can appreciate our position as a responsible retailer, which is to offer a wide variety of products and services to the many customers we serve.

Thank you for your feedback. We will continue to monitor your concern and make any necessary adjustments.

Regards, Amber Shoppers Drug Mart / Pharmaprix Customer Service

That's right, you read it well. They consider banning the sale of cigarettes a form of censorship, and they hide themselves behind the legality of the product. At least I would have taken "we do it for the money" as a valid reason. But censorship?