Re: [Tracker] Uninitialized variable in tracker-files.c



On 09/12/08 11:57, Luca Ferretti wrote:
Il giorno mar, 09/12/2008 alle 09.38 +0000, Martyn Russell ha scritto:
On 08/12/08 19:54, Luca Ferretti wrote:
I was checking tracker-utils/*c due to some localization issues (more on
this later). In tracker-files.c shouldn't it be:

   static gint      limit = 512;
-static gint        offset;
+static gint        offset = 0;
Hi,

As far as I am aware, the compiler should initialize variables not set
in static statements to NULL or 0.

All compilers (gcc, sun, ibm)?

That's a good question indeed. As far as I know, this is something the compiler does. I am not entirely sure how much support exists here across compilers. What I do know though, is that we do this a LOT in the code for static variables. So if this isn't covered by your compiler, expect strange results from Tracker in general.

Note: GLib and GTK+ also do this. That's not to say we should or shouldn't but then they (and we) are heavily biased to gcc.

The only reason we do it for limit is
because we want something other than 0 of course.

Better code readability?

That's a style preference. Seeing a list of initialised variables vs. seeing 1 or 2 so I know which ones have a default value is easier for me to read. But really, it makes no difference.

I think one way or the other should be decided project wise and not just done in the utils. Right now we do it the way it is everywhere else.

While it's not needed, I can't see any issue adding them. I'm reviewing
that GOption stuff, so I could add NULL, 0 and FALSE at the same time..

Please don't. Unless there is a good enough reason to change them other than style. It is better to remain consistent with the rest of the Tracker project.

--
Regards,
Martyn



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]