* Benjamin Poirier ([email protected]) wrote:
> On 24/01/11 01:05 PM, Yannick Brosseau wrote:
>> Mostly wrong usages of g_error
>>
> [...]
>> @@ -550,7 +550,7 @@ static void analyzeMessageEval(SyncState* const 
>> syncState, Message* const
>>      message)
>>   {
>>      AnalysisDataEval* analysisData= syncState->analysisData;
>> -    MessageStats* messageStats;
>> +    MessageStats* messageStats = NULL;
>
> I'd like to mention that the warning
> sync/event_analysis_eval.c:553: warning: ‘messageStats’ may be used  
> uninitialized in this function
>
> goes away when you configure and compile with CFLAGS=-O0 so I thought it  
> might be a compiler glitch. Any insight on that?

gcc does not seem to the able to figure out that syncState->stats value
will stay the same for the whole function, but it clearly does.

It leads me to wonder why you declare:

SyncState* const syncState

instead of either of:

const SyncState * syncState
or SyncState const * syncState

Because your version applies the const qualifier on the pointer, not the
structure. The two versions I propose below apply the const qualifier to
the SyncState type.

Thanks,

Mathieu

>
> -Ben
>
>
>>      double* rtt;
>>      double tt;
>>      struct RttKey rttKey;
>> @@ -1111,7 +1111,7 @@ static void readRttInfo(GHashTable* rttInfo, FILE* 
>> rttStream)
>>
>>              if (retval == -1&&  !feof(rttStream))
>>              {
>> -                    g_error(strerror(errno));
>> +                    g_error("%s", strerror(errno));
>>              }
>>
>>              if (line[retval - 1] == '\n')
>> @@ -1124,7 +1124,7 @@ static void readRttInfo(GHashTable* rttInfo, FILE* 
>> rttStream)
>>                      &tmp);
>>              if (retval == EOF)
>>              {
>> -                    g_error(strerror(errno));
>> +                    g_error("%s", strerror(errno));
>>              }
>>              else if (retval != 3)
>>              {
>> @@ -1187,7 +1187,7 @@ static void positionStream(FILE* stream)
>>                              }
>>                              else
>>                              {
>> -                                    g_error(strerror(errno));
>> +                                    g_error("%s", strerror(errno));
>>                              }
>>                      }
>>              }
>> diff --git a/lttv/lttv/sync/event_matching_broadcast.c 
>> b/lttv/lttv/sync/event_matching_broadcast.c
>> index 9c83d9c..4c66d18 100644
>> --- a/lttv/lttv/sync/event_matching_broadcast.c
>> +++ b/lttv/lttv/sync/event_matching_broadcast.c
>> @@ -382,7 +382,7 @@ static void openGraphDataFiles(SyncState* const 
>> syncState)
>>                      g_assert_cmpint(retval,<=, sizeof(name) - 1);
>>                      if ((graphs->accuracyPoints[i][j]= fopen(name, "w")) == 
>> NULL)
>>                      {
>> -                            g_error(strerror(errno));
>> +                            g_error("%s", strerror(errno));
>>                      }
>>              }
>>      }
>> @@ -390,7 +390,7 @@ static void openGraphDataFiles(SyncState* const 
>> syncState)
>>      retval= chdir(cwd);
>>      if (retval == -1)
>>      {
>> -            g_error(strerror(errno));
>> +            g_error("%s", strerror(errno));
>>      }
>>      free(cwd);
>>   }
>> @@ -460,7 +460,7 @@ static void closeGraphDataFiles(SyncState* const 
>> syncState)
>>                      retval= fclose(graphs->accuracyPoints[i][j]);
>>                      if (retval != 0)
>>                      {
>> -                            g_error(strerror(errno));
>> +                            g_error("%s", strerror(errno));
>>                      }
>>              }
>>              free(graphs->accuracyPoints[i]);
>> diff --git a/lttv/lttv/sync/event_matching_tcp.c 
>> b/lttv/lttv/sync/event_matching_tcp.c
>> index 90d6c43..2d4fe51 100644
>> --- a/lttv/lttv/sync/event_matching_tcp.c
>> +++ b/lttv/lttv/sync/event_matching_tcp.c
>> @@ -604,7 +604,7 @@ static void openGraphDataFiles(SyncState* const 
>> syncState)
>>                              if ((matchingData->messagePoints[i][j]= 
>> fopen(name, "w")) ==
>>                                      NULL)
>>                              {
>> -                                    g_error(strerror(errno));
>> +                                    g_error("%s", strerror(errno));
>>                              }
>>                      }
>>              }
>> @@ -613,7 +613,7 @@ static void openGraphDataFiles(SyncState* const 
>> syncState)
>>      retval= chdir(cwd);
>>      if (retval == -1)
>>      {
>> -            g_error(strerror(errno));
>> +            g_error("%s", strerror(errno));
>>      }
>>      free(cwd);
>>   }
>> @@ -676,7 +676,7 @@ static void closeGraphDataFiles(SyncState* const 
>> syncState)
>>                              retval= 
>> fclose(matchingData->messagePoints[i][j]);
>>                              if (retval != 0)
>>                              {
>> -                                    g_error(strerror(errno));
>> +                                    g_error("%s", strerror(errno));
>>                              }
>>                      }
>>              }
>> diff --git a/lttv/lttv/sync/graph_functions.c 
>> b/lttv/lttv/sync/graph_functions.c
>> index c347b24..91feef0 100644
>> --- a/lttv/lttv/sync/graph_functions.c
>> +++ b/lttv/lttv/sync/graph_functions.c
>> @@ -55,11 +55,11 @@ FILE* createGraphsDir(const char* const graphsDir)
>>                              S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP 
>> | S_IROTH
>>                              | S_IWOTH | S_IXOTH)) == -1)
>>      {
>> -            g_error(strerror(errno));
>> +            g_error("%s", strerror(errno));
>>      }
>>      if ((result= fdopen(graphsFp, "w")) == NULL)
>>      {
>> -            g_error(strerror(errno));
>> +            g_error("%s", strerror(errno));
>>      }
>>
>>      fprintf(result,
>> @@ -69,7 +69,7 @@ FILE* createGraphsDir(const char* const graphsDir)
>>      retval= chdir(cwd);
>>      if (retval == -1)
>>      {
>> -            g_error(strerror(errno));
>> +            g_error("%s", strerror(errno));
>>      }
>>      free(cwd);
>>
>> @@ -95,7 +95,7 @@ char* changeToGraphsDir(const char* const graphsDir)
>>      cwd= getcwd(NULL, 0);
>>      if (cwd == NULL)
>>      {
>> -            g_error(strerror(errno));
>> +            g_error("%s", strerror(errno));
>>      }
>>      while ((retval= chdir(graphsDir)) != 0)
>>      {
>> @@ -105,12 +105,12 @@ char* changeToGraphsDir(const char* const graphsDir)
>>                              S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | 
>> S_IXOTH);
>>                      if (retval != 0)
>>                      {
>> -                            g_error(strerror(errno));
>> +                            g_error("%s", strerror(errno));
>>                      }
>>              }
>>              else
>>              {
>> -                    g_error(strerror(errno));
>> +                    g_error("%s", strerror(errno));
>>              }
>>      }
>>
>> @@ -233,11 +233,11 @@ void writeGraphsScript(SyncState* const syncState)
>>
>>                              if (ftruncate(fileno(syncState->graphsStream), 
>> trunc) == -1)
>>                              {
>> -                                    g_error(strerror(errno));
>> +                                    g_error("%s", strerror(errno));
>>                              }
>>                              if (fseek(syncState->graphsStream, 0, SEEK_END) 
>> == -1)
>>                              {
>> -                                    g_error(strerror(errno));
>> +                                    g_error("%s", strerror(errno));
>>                              }
>>
>>                              fprintf(syncState->graphsStream,
>> diff --git a/lttv/lttv/sync/sync_chain_lttv.c 
>> b/lttv/lttv/sync/sync_chain_lttv.c
>> index 95bef44..bb49bbd 100644
>> --- a/lttv/lttv/sync/sync_chain_lttv.c
>> +++ b/lttv/lttv/sync/sync_chain_lttv.c
>> @@ -388,7 +388,7 @@ bool syncTraceset(LttvTracesetContext* const 
>> traceSetContext)
>>
>>              if (fclose(syncState->graphsStream) != 0)
>>              {
>> -                    g_error(strerror(errno));
>> +                    g_error("%s", strerror(errno));
>>              }
>>      }
>>
>
>
> _______________________________________________
> ltt-dev mailing list
> [email protected]
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
ltt-dev mailing list
[email protected]
http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev

Reply via email to