[libgsf] Objects: stop handling NULL from g_object_new.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] Objects: stop handling NULL from g_object_new.
- Date: Mon, 7 Jan 2013 19:00:49 +0000 (UTC)
commit 7b5dd958a7dbae54dacd01f91e88bccc9882dda9
Author: Morten Welinder <terra gnome org>
Date: Mon Jan 7 13:59:44 2013 -0500
Objects: stop handling NULL from g_object_new.
1. It won't happen.
2. If it did, we're surely only handling half of the cases.
3. No-one else does.
4. We aren't testing those paths.
ChangeLog | 4 ++++
gsf/gsf-blob.c | 1 -
gsf/gsf-clip-data.c | 1 -
gsf/gsf-infile-ar.c | 2 --
gsf/gsf-infile-msole.c | 4 ----
gsf/gsf-infile-msvba.c | 2 --
gsf/gsf-infile-stdio.c | 6 +-----
gsf/gsf-infile-zip.c | 2 --
gsf/gsf-input-gio.c | 5 -----
gsf/gsf-input-gzip.c | 4 ----
gsf/gsf-input-http.c | 1 -
gsf/gsf-input-memory.c | 6 ------
gsf/gsf-input-proxy.c | 1 -
gsf/gsf-input-stdio.c | 6 ------
gsf/gsf-input-textline.c | 3 ---
gsf/gsf-outfile-msole.c | 1 -
gsf/gsf-output-bzip.c | 1 -
gsf/gsf-output-gio.c | 6 ------
gsf/gsf-output-gzip.c | 1 -
gsf/gsf-output-iochannel.c | 1 -
gsf/gsf-output-stdio.c | 2 --
gsf/gsf-output-transaction.c | 1 -
gsf/gsf-shared-memory.c | 3 ---
gsf/gsf-structured-blob.c | 2 --
24 files changed, 5 insertions(+), 61 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 734ddd2..15cf4f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-07 Morten Welinder <terra gnome org>
+
+ * gsf/*.c: Stop pretending that g_object_new can return NULL.
+
2013-01-05 Morten Welinder <terra gnome org>
* gsf/gsf-output-gio.c (gsf_output_gio_new_full): New function
diff --git a/gsf/gsf-blob.c b/gsf/gsf-blob.c
index a2e62a7..5382b1c 100644
--- a/gsf/gsf-blob.c
+++ b/gsf/gsf-blob.c
@@ -123,7 +123,6 @@ gsf_blob_new (gsize size, gconstpointer data_to_copy, GError **error)
data = NULL;
blob = g_object_new (GSF_TYPE_BLOB, NULL);
- if (G_UNLIKELY (NULL == blob)) return NULL;
priv = blob->priv;
diff --git a/gsf/gsf-clip-data.c b/gsf/gsf-clip-data.c
index fa2bc04..60f80b0 100644
--- a/gsf/gsf-clip-data.c
+++ b/gsf/gsf-clip-data.c
@@ -103,7 +103,6 @@ gsf_clip_data_new (GsfClipFormat format, GsfBlob *data_blob)
g_return_val_if_fail (GSF_IS_BLOB (data_blob), NULL);
clip_data = g_object_new (GSF_TYPE_CLIP_DATA, NULL);
- if (G_UNLIKELY (NULL == clip_data)) return NULL;
priv = clip_data->priv;
diff --git a/gsf/gsf-infile-ar.c b/gsf/gsf-infile-ar.c
index 6cbf07e..1697446 100644
--- a/gsf/gsf-infile-ar.c
+++ b/gsf/gsf-infile-ar.c
@@ -267,7 +267,6 @@ ar_dup (GsfInfileAr const *src)
g_return_val_if_fail (src != NULL, NULL);
dst = g_object_new (GSF_INFILE_AR_TYPE, NULL);
- if (G_UNLIKELY (NULL == dst)) return NULL;
dst->input = gsf_input_dup (src->input, NULL);
dst->info = ar_info_ref (src->info);
@@ -469,7 +468,6 @@ gsf_infile_ar_new (GsfInput *source, GError **err)
g_return_val_if_fail (GSF_IS_INPUT (source), NULL);
ar = g_object_new (GSF_INFILE_AR_TYPE, NULL);
- if (G_UNLIKELY (NULL == ar)) return NULL;
g_object_ref (source);
ar->input = source;
diff --git a/gsf/gsf-infile-msole.c b/gsf/gsf-infile-msole.c
index b00fe6a..4891d01 100644
--- a/gsf/gsf-infile-msole.c
+++ b/gsf/gsf-infile-msole.c
@@ -452,8 +452,6 @@ ole_dup (GsfInfileMSOle const *src, GError **err)
}
dst = (GsfInfileMSOle *)g_object_new (GSF_INFILE_MSOLE_TYPE, NULL);
- if (G_UNLIKELY (NULL == dst)) return NULL;
-
dst->input = input;
dst->info = ole_info_ref (src->info);
/* buf and buf_size are initialized to NULL */
@@ -930,8 +928,6 @@ gsf_infile_msole_new (GsfInput *source, GError **err)
g_return_val_if_fail (GSF_IS_INPUT (source), NULL);
ole = (GsfInfileMSOle *)g_object_new (GSF_INFILE_MSOLE_TYPE, NULL);
- if (G_UNLIKELY (NULL == ole)) return NULL;
-
ole->input = gsf_input_proxy_new (source);
gsf_input_set_size (GSF_INPUT (ole), 0);
diff --git a/gsf/gsf-infile-msvba.c b/gsf/gsf-infile-msvba.c
index 9f116fd..4c7bbf2 100644
--- a/gsf/gsf-infile-msvba.c
+++ b/gsf/gsf-infile-msvba.c
@@ -493,8 +493,6 @@ gsf_infile_msvba_new (GsfInfile *source, GError **err)
g_return_val_if_fail (GSF_IS_INFILE (source), NULL);
vba = g_object_new (GSF_INFILE_MSVBA_TYPE, NULL);
- if (G_UNLIKELY (NULL == vba)) return NULL;
-
vba->source = g_object_ref (source);
/* vba_project_read (vba, err); */
diff --git a/gsf/gsf-infile-stdio.c b/gsf/gsf-infile-stdio.c
index 82956aa..69b5389 100644
--- a/gsf/gsf-infile-stdio.c
+++ b/gsf/gsf-infile-stdio.c
@@ -68,8 +68,6 @@ gsf_infile_stdio_dup (GsfInput *src_input, G_GNUC_UNUSED GError **err)
GsfInfileStdio *src = GSF_INFILE_STDIO (src_input);
GsfInfileStdio *dst = g_object_new (GSF_INFILE_STDIO_TYPE, NULL);
- if (G_UNLIKELY (NULL == dst)) return NULL;
-
dst->root = g_strdup (src->root);
for (ptr = src->children; ptr != NULL ; ptr = ptr->next)
@@ -185,13 +183,11 @@ gsf_infile_stdio_new (char const *root, GError **err)
GDir *dir;
char const *child;
- ifs = g_object_new (GSF_INFILE_STDIO_TYPE, NULL);
- if (G_UNLIKELY (NULL == ifs)) return NULL;
-
dir = g_dir_open (root, 0, err);
if (dir == NULL)
return NULL;
+ ifs = g_object_new (GSF_INFILE_STDIO_TYPE, NULL);
ifs->root = g_strdup (root);
while ((child = g_dir_read_name (dir)))
diff --git a/gsf/gsf-infile-zip.c b/gsf/gsf-infile-zip.c
index 890b25c..549dacf 100644
--- a/gsf/gsf-infile-zip.c
+++ b/gsf/gsf-infile-zip.c
@@ -274,7 +274,6 @@ zip_dup (GsfInfileZip const *src, GError **err)
dst = g_object_new (GSF_INFILE_ZIP_TYPE,
"internal-parent", src,
NULL);
- if (G_UNLIKELY (NULL == dst)) return NULL;
if (dst->err) {
if (err)
@@ -876,7 +875,6 @@ gsf_infile_zip_new (GsfInput *source, GError **err)
zip = g_object_new (GSF_INFILE_ZIP_TYPE,
"source", source,
NULL);
- if (G_UNLIKELY (NULL == zip)) return NULL;
if (zip->err) {
if (err)
diff --git a/gsf/gsf-input-gio.c b/gsf/gsf-input-gio.c
index 482c166..43037d4 100644
--- a/gsf/gsf-input-gio.c
+++ b/gsf/gsf-input-gio.c
@@ -148,11 +148,6 @@ gsf_input_gio_new (GFile *file, GError **err)
}
input = g_object_new (GSF_INPUT_GIO_TYPE, NULL);
- if (G_UNLIKELY (NULL == input)) {
- g_input_stream_close (stream, NULL, NULL);
- g_object_unref (stream);
- return NULL;
- }
gsf_input_set_size (GSF_INPUT (input), filesize);
diff --git a/gsf/gsf-input-gzip.c b/gsf/gsf-input-gzip.c
index 0c1bec3..c842471 100644
--- a/gsf/gsf-input-gzip.c
+++ b/gsf/gsf-input-gzip.c
@@ -215,7 +215,6 @@ gsf_input_gzip_new (GsfInput *source, GError **err)
gzip = g_object_new (GSF_INPUT_GZIP_TYPE,
"source", source,
NULL);
- if (G_UNLIKELY (NULL == gzip)) return NULL;
if (gzip->err) {
if (err)
@@ -267,9 +266,6 @@ gsf_input_gzip_dup (GsfInput *src_input, GError **err)
if (src_source_copy)
g_object_unref (src_source_copy);
- if (G_UNLIKELY (NULL == dst))
- return NULL;
-
if (src->err) {
g_clear_error (&dst->err);
dst->err = g_error_copy (src->err);
diff --git a/gsf/gsf-input-http.c b/gsf/gsf-input-http.c
index 9b78e14..a8afeb2 100644
--- a/gsf/gsf-input-http.c
+++ b/gsf/gsf-input-http.c
@@ -239,7 +239,6 @@ gsf_input_http_new (gchar const * url, GError **error G_GNUC_UNUSED)
"url", url,
"content-type", content_type,
NULL);
- if (G_UNLIKELY (NULL == obj)) return NULL;
gsf_input_set_size (GSF_INPUT (obj), xmlNanoHTTPContentLength (ctx));
GSF_INPUT_HTTP (obj)->ctx = ctx;
diff --git a/gsf/gsf-input-memory.c b/gsf/gsf-input-memory.c
index e967faf..fdce203 100644
--- a/gsf/gsf-input-memory.c
+++ b/gsf/gsf-input-memory.c
@@ -63,8 +63,6 @@ GsfInput *
gsf_input_memory_new (guint8 const *buf, gsf_off_t length, gboolean needs_free)
{
GsfInputMemory *mem = g_object_new (GSF_INPUT_MEMORY_TYPE, NULL);
- if (G_UNLIKELY (NULL == mem)) return NULL;
-
mem->shared = gsf_shared_memory_new ((void *)buf, length, needs_free);
gsf_input_set_size (GSF_INPUT (mem), length);
return GSF_INPUT (mem);
@@ -87,8 +85,6 @@ gsf_input_memory_new_clone (guint8 const *buf, gsf_off_t length)
g_return_val_if_fail (length >= 0, NULL);
mem = g_object_new (GSF_INPUT_MEMORY_TYPE, NULL);
- if (G_UNLIKELY (NULL == mem)) return NULL;
-
cpy = g_try_malloc (MAX (1, length) * sizeof (guint8));
if (cpy == NULL) {
g_object_unref (mem);
@@ -116,7 +112,6 @@ gsf_input_memory_dup (GsfInput *src_input, G_GNUC_UNUSED GError **err)
{
GsfInputMemory const *src = (GsfInputMemory *) (src_input);
GsfInputMemory *dst = g_object_new (GSF_INPUT_MEMORY_TYPE, NULL);
- if (G_UNLIKELY (NULL == dst)) return NULL;
dst->shared = g_object_ref (src->shared);
gsf_input_set_size (GSF_INPUT (dst), src->shared->size);
@@ -211,7 +206,6 @@ gsf_input_mmap_new (char const *filename, GError **err)
size_t size;
mem = g_object_new (GSF_INPUT_MEMORY_TYPE, NULL);
- if (G_UNLIKELY (NULL == mem)) return NULL;
fd = g_open (filename, O_RDONLY | O_BINARY, 0);
if (fd < 0 || fstat (fd, &st) < 0) {
diff --git a/gsf/gsf-input-proxy.c b/gsf/gsf-input-proxy.c
index c7f97fb..15c0578 100644
--- a/gsf/gsf-input-proxy.c
+++ b/gsf/gsf-input-proxy.c
@@ -72,7 +72,6 @@ gsf_input_proxy_new_section (GsfInput *source,
g_return_val_if_fail (size <= source_size - offset, NULL);
proxy = g_object_new (GSF_INPUT_PROXY_TYPE, NULL);
- if (G_UNLIKELY (NULL == proxy)) return NULL;
proxy->offset = offset;
gsf_input_set_size (GSF_INPUT (proxy), size);
diff --git a/gsf/gsf-input-stdio.c b/gsf/gsf-input-stdio.c
index fc8f913..a5496fa 100644
--- a/gsf/gsf-input-stdio.c
+++ b/gsf/gsf-input-stdio.c
@@ -145,11 +145,6 @@ gsf_input_stdio_new (char const *filename, GError **err)
size = st.st_size;
input = (GsfInputStdio *)g_object_new (GSF_INPUT_STDIO_TYPE, NULL);
- if (G_UNLIKELY (NULL == input)) {
- fclose (file);
- return NULL;
- }
-
input->file = file;
input->filename = g_strdup (filename);
input->buf = NULL;
@@ -190,7 +185,6 @@ gsf_input_stdio_new_FILE (char const *filename, FILE *file, gboolean keep_open)
size = st.st_size;
stdio = g_object_new (GSF_INPUT_STDIO_TYPE, NULL);
- if (G_UNLIKELY (NULL == stdio)) return NULL;
stdio->file = file;
stdio->keep_open = keep_open;
stdio->filename = g_strdup (filename);
diff --git a/gsf/gsf-input-textline.c b/gsf/gsf-input-textline.c
index 56327ab..4e44f0b 100644
--- a/gsf/gsf-input-textline.c
+++ b/gsf/gsf-input-textline.c
@@ -62,8 +62,6 @@ gsf_input_textline_new (GsfInput *source)
g_return_val_if_fail (source != NULL, NULL);
input = g_object_new (GSF_INPUT_TEXTLINE_TYPE, NULL);
- if (G_UNLIKELY (NULL == input)) return NULL;
-
input->source = g_object_ref (source);
input->buf = NULL;
input->buf_size = 0;
@@ -94,7 +92,6 @@ gsf_input_textline_dup (GsfInput *src_input, G_GNUC_UNUSED GError **err)
{
GsfInputTextline const *src = (GsfInputTextline *)src_input;
GsfInputTextline *dst = g_object_new (GSF_INPUT_TEXTLINE_TYPE, NULL);
- if (G_UNLIKELY (NULL == dst)) return NULL;
dst->source = g_object_ref (src->source);
gsf_input_set_size (GSF_INPUT (dst), gsf_input_size (src_input));
diff --git a/gsf/gsf-outfile-msole.c b/gsf/gsf-outfile-msole.c
index 4f362cb..f9be6f2 100644
--- a/gsf/gsf-outfile-msole.c
+++ b/gsf/gsf-outfile-msole.c
@@ -728,7 +728,6 @@ gsf_outfile_msole_new_full (GsfOutput *sink, guint bb_size, guint sb_size)
g_return_val_if_fail (GSF_IS_OUTPUT (sink), NULL);
ole = g_object_new (GSF_OUTFILE_MSOLE_TYPE, NULL);
- if (G_UNLIKELY (NULL == ole)) return NULL;
g_object_ref (sink);
ole->sink = sink;
diff --git a/gsf/gsf-output-bzip.c b/gsf/gsf-output-bzip.c
index acac074..1b2dcb6 100644
--- a/gsf/gsf-output-bzip.c
+++ b/gsf/gsf-output-bzip.c
@@ -252,7 +252,6 @@ gsf_output_bzip_new (GsfOutput *sink, GError **err)
g_return_val_if_fail (GSF_IS_OUTPUT (sink), NULL);
bzip = g_object_new (GSF_OUTPUT_BZIP_TYPE, NULL);
- if (G_UNLIKELY (NULL == bzip)) return NULL;
g_object_ref (sink);
bzip->sink = sink;
diff --git a/gsf/gsf-output-gio.c b/gsf/gsf-output-gio.c
index 8faf5f2..ce43660 100644
--- a/gsf/gsf-output-gio.c
+++ b/gsf/gsf-output-gio.c
@@ -75,12 +75,6 @@ gsf_output_gio_new_full (GFile *file, GError **err)
}
output = g_object_new (GSF_OUTPUT_GIO_TYPE, NULL);
- if (G_UNLIKELY (NULL == output)) {
- g_output_stream_close (stream, NULL, NULL);
- g_object_unref (stream);
- return NULL;
- }
-
output->file = file;
output->stream = stream;
g_object_ref (output->file);
diff --git a/gsf/gsf-output-gzip.c b/gsf/gsf-output-gzip.c
index 8edd195..61f60fa 100644
--- a/gsf/gsf-output-gzip.c
+++ b/gsf/gsf-output-gzip.c
@@ -123,7 +123,6 @@ gsf_output_gzip_new (GsfOutput *sink, GError **err)
g_return_val_if_fail (GSF_IS_OUTPUT (sink), NULL);
output = g_object_new (GSF_OUTPUT_GZIP_TYPE, "sink", sink, NULL);
- if (G_UNLIKELY (NULL == output)) return NULL;
con_err = gsf_output_error (output);
diff --git a/gsf/gsf-output-iochannel.c b/gsf/gsf-output-iochannel.c
index c3785ae..4f0936b 100644
--- a/gsf/gsf-output-iochannel.c
+++ b/gsf/gsf-output-iochannel.c
@@ -48,7 +48,6 @@ gsf_output_iochannel_new (GIOChannel *channel)
g_return_val_if_fail (channel != NULL, NULL);
output = g_object_new (GSF_OUTPUT_IOCHANNEL_TYPE, NULL);
- if (G_UNLIKELY (NULL == output)) return NULL;
output->channel = channel;
return GSF_OUTPUT (output);
diff --git a/gsf/gsf-output-stdio.c b/gsf/gsf-output-stdio.c
index f596a86..4eb8100 100644
--- a/gsf/gsf-output-stdio.c
+++ b/gsf/gsf-output-stdio.c
@@ -587,8 +587,6 @@ gsf_output_stdio_new_FILE (char const *filename, FILE *file, gboolean keep_open)
g_return_val_if_fail (file != NULL, NULL);
stdio = g_object_new (GSF_OUTPUT_STDIO_TYPE, NULL);
- if (G_UNLIKELY (NULL == stdio)) return NULL;
-
stdio->file = file;
stdio->keep_open = keep_open;
stdio->real_filename = stdio->temp_filename = NULL;
diff --git a/gsf/gsf-output-transaction.c b/gsf/gsf-output-transaction.c
index d632e2f..cd5c190 100644
--- a/gsf/gsf-output-transaction.c
+++ b/gsf/gsf-output-transaction.c
@@ -138,7 +138,6 @@ gsf_output_transaction_new_named (GsfOutput *wrapped, char const *name)
g_return_val_if_fail (name != NULL, NULL);
trans = g_object_new (GSF_OUTPUT_TRANSACTION_TYPE, NULL);
- if (G_UNLIKELY (NULL == trans)) return NULL;
gsf_output_set_name (GSF_OUTPUT (trans), name);
diff --git a/gsf/gsf-shared-memory.c b/gsf/gsf-shared-memory.c
index c098019..2cf7237 100644
--- a/gsf/gsf-shared-memory.c
+++ b/gsf/gsf-shared-memory.c
@@ -40,8 +40,6 @@ GsfSharedMemory *
gsf_shared_memory_new (void *buf, gsf_off_t size, gboolean needs_free)
{
GsfSharedMemory *mem = g_object_new (GSF_SHARED_MEMORY_TYPE, NULL);
- if (G_UNLIKELY (NULL == mem)) return NULL;
-
mem->buf = buf;
mem->size = size;
mem->needs_free = needs_free;
@@ -59,7 +57,6 @@ gsf_shared_memory_mmapped_new (void *buf, gsf_off_t size)
return NULL;
} else {
GsfSharedMemory *mem = gsf_shared_memory_new (buf, size, FALSE);
- if (G_UNLIKELY (NULL == mem)) return NULL;
mem->needs_unmap = TRUE;
return mem;
}
diff --git a/gsf/gsf-structured-blob.c b/gsf/gsf-structured-blob.c
index 03ac789..50d8d5b 100644
--- a/gsf/gsf-structured-blob.c
+++ b/gsf/gsf-structured-blob.c
@@ -67,7 +67,6 @@ blob_dup (GsfInput *input, G_GNUC_UNUSED GError **err)
{
GsfStructuredBlob const *src = (GsfStructuredBlob *) input;
GsfStructuredBlob *dst = g_object_new (GSF_STRUCTURED_BLOB_TYPE, NULL);
- if (G_UNLIKELY (NULL == dst)) return NULL;
if (src->data != NULL)
dst->data = g_object_ref (src->data);
@@ -210,7 +209,6 @@ gsf_structured_blob_read (GsfInput *input)
g_return_val_if_fail (GSF_IS_INPUT (input), NULL);
blob = g_object_new (GSF_STRUCTURED_BLOB_TYPE, NULL);
- if (G_UNLIKELY (NULL == blob)) return NULL;
content_size = gsf_input_remaining (input);
if (content_size > 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]