pspp-dev
[Top][All Lists]
Advanced

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

Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict


From: John Darrington
Subject: Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable().
Date: Tue, 17 Apr 2012 06:20:10 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

On Mon, Apr 16, 2012 at 08:52:07PM -0700, Ben Pfaff wrote:
     Also, as long as we're checking for too-big we might as well check
     for too-small too.
     ---
      src/ui/gui/psppire-dict.c |    8 ++------
      1 files changed, 2 insertions(+), 6 deletions(-)
     
     diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c
     index 04bd3e3..32f46f2 100644
     --- a/src/ui/gui/psppire-dict.c
     +++ b/src/ui/gui/psppire-dict.c
     @@ -464,17 +464,13 @@ psppire_dict_set_name (PsppireDict* d, gint idx, 
const gchar *name)
      
     +  g_return_val_if_fail (idx < 0 || dict_get_var_cnt (d->dict) <= idx, 
NULL);

Personally I prefer assertions to be written in their separate components 
rather than ored 
together, like this:

 g_return_val_if_fail (idx < 0, NULL);
 g_return_val_if_fail (dict_get_var_cnt (d->dict) <= idx, NULL);
   
That way, when the condition fails, it's easier to find out which part of the 
condition is failing.

J'

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://keys.gnupg.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]