[Top][All Lists]
[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.
signature.asc
Description: Digital signature
- [PATCH 00/13] second batch of psppsheet changes, Ben Pfaff, 2012/04/16
- [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., Ben Pfaff, 2012/04/16
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable().,
John Darrington <=
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., Ben Pfaff, 2012/04/18
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., John Darrington, 2012/04/18
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., Ben Pfaff, 2012/04/19
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., Ben Pfaff, 2012/04/21
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., John Darrington, 2012/04/21
[PATCH 02/13] gui: Use canonical names for signals., Ben Pfaff, 2012/04/16
[PATCH 03/13] gui: Add undocumented --measure-startup option., Ben Pfaff, 2012/04/16
[PATCH 04/13] gui: Call g_thread_init() earlier., Ben Pfaff, 2012/04/16