summaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-05-30 17:39:34 +0000
committerTom Tromey <tromey@redhat.com>2013-05-30 17:39:34 +0000
commit9a9a177185ba7001908265435d00f0eb2ebfe3cf (patch)
tree57ecea31fb37dae7b0623b371897f504219bb6dc /gdb/utils.c
parentc260d1c1076b7376edf5e78a35387e490a6a7c1b (diff)
downloadgdb-9a9a177185ba7001908265435d00f0eb2ebfe3cf.tar.gz
fix compile_rx_or_error
compile_rx_or_error looks like a constructor, but it can return NULL. This patch changes it to remove the NULL return, making it work like any other cleanup constructor. This is a stylistic patch but I think it is also better for code to follow the normal conventions. * probe.c (collect_probes): Check arguments for NULL before calling compile_rx_or_error. * utils.c (compile_rx_or_error): Require 'rx' to be non-NULL. Remove NULL return.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index c25dadfe286..18ee9bbf98b 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1127,16 +1127,15 @@ get_regcomp_error (int code, regex_t *rx)
}
/* Compile a regexp and throw an exception on error. This returns a
- cleanup to free the resulting pattern on success. If RX is NULL,
- this does nothing and returns NULL. */
+ cleanup to free the resulting pattern on success. RX must not be
+ NULL. */
struct cleanup *
compile_rx_or_error (regex_t *pattern, const char *rx, const char *message)
{
int code;
- if (!rx)
- return NULL;
+ gdb_assert (rx != NULL);
code = regcomp (pattern, rx, REG_NOSUB);
if (code != 0)