[Pidgin] #1344: fix for some build warnings

Pidgin trac at pidgin.im
Tue May 29 15:09:28 EDT 2007


#1344: fix for some build warnings
----------------------------+-----------------------------------------------
  Reporter:  o_sukhodolsky  |       Owner:  rlaager 
      Type:  patch          |      Status:  assigned
  Priority:  minor          |   Milestone:  2.0.2   
 Component:  pidgin (gtk)   |     Version:  2.0.1   
Resolution:                 |    Keywords:          
   Pending:  0              |  
----------------------------+-----------------------------------------------
Comment (by rlaager):

 Replying to [comment:5 o_sukhodolsky]:
 > Replying to [comment:3 rlaager]:
 > > I don't think that g_return_if_fail() is acceptable here. Those checks
 can be compiled out. I think this sort of error checking should be done
 with unconditional if statements.
 > > {{{
 > > 498         +  result = fwrite(data->data, 1, data->len, fp);
 > > 499         +  g_return_if_fail(result == data->len);
 > > }}}
 >
 > well, I think that g_malloc() can return NULL in the same case as
 malloc() though it is not documented :(  Anyway it looks like you do not
 care about this case, so I'm ok to not do this check.

 g_malloc() only returns NULL if you pass a length of 0. This is impossible
 in this case, as we're adding two to the data length anyway. (Well, if
 that's -2 or something, I suppose, but that really shouldn't be
 happening.) malloc() returns NULL when it can't allocate memory. If you
 ask g_malloc() for memory, it asks malloc(). If malloc() returns NULL,
 g_malloc() calls abort() and the application terminates.

-- 
Ticket URL: <http://developer.pidgin.im/ticket/1344#comment:9>
Pidgin <http://pidgin.im>
Pidgin


More information about the Tracker mailing list