[sysprof] line-reader: handle invalid parameters more gracefully
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] line-reader: handle invalid parameters more gracefully
- Date: Mon, 22 Aug 2016 18:04:57 +0000 (UTC)
commit e4e1bf73b36b17230104544e73b686fd6635d2de
Author: Christian Hergert <chergert redhat com>
Date: Mon Aug 22 11:02:03 2016 -0700
line-reader: handle invalid parameters more gracefully
This silences coverity which doesn't handle return_if_fail() macros
very well.
lib/sp-line-reader.c | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/lib/sp-line-reader.c b/lib/sp-line-reader.c
index 174ed98..35c8814 100644
--- a/lib/sp-line-reader.c
+++ b/lib/sp-line-reader.c
@@ -51,28 +51,22 @@ SpLineReader *
sp_line_reader_new (const gchar *contents,
gssize length)
{
- SpLineReader *self;
+ SpLineReader *self = g_slice_new (SpLineReader);
- g_return_val_if_fail (contents != NULL, NULL);
-
- self = g_slice_new (SpLineReader);
-
- if (length < 0)
- length = strlen (contents);
-
- if (contents != NULL)
+ if (contents == NULL)
{
- self->contents = contents;
- self->length = length;
- self->pos = 0;
+ contents = "";
+ length = 0;
}
- else
+ else if (length < 0)
{
- self->contents = NULL;
- self->length = 0;
- self->pos = 0;
+ length = strlen (contents);
}
+ self->contents = contents;
+ self->length = length;
+ self->pos = 0;
+
return self;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]