[bijiben] src: Move all declarations to the top of blocks
- From: Jonathan Kang <jonathankang src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] src: Move all declarations to the top of blocks
- Date: Sun, 23 Apr 2017 13:11:58 +0000 (UTC)
commit 3f4faecf8f718ea79de61b5fd9dfb51eac6fe571
Author: Philip Withnall <philip withnall collabora co uk>
Date: Sun Apr 23 21:03:44 2017 +0800
src: Move all declarations to the top of blocks
This fixes C90 style, which makes it easier to see all the memory a
function allocates or handles throughout its body.
https://bugzilla.gnome.org/show_bug.cgi?id=762648
src/bjb-bijiben.c | 3 ++-
src/bjb-import-dialog.c | 4 ++--
src/bjb-main-toolbar.c | 4 +++-
src/libbiji/biji-manager.c | 6 +++---
src/libbiji/biji-note-obj.c | 12 ++++++++----
src/libbiji/editor/biji-webkit-editor.c | 12 +++++++-----
src/libbiji/provider/biji-import-provider.c | 10 ++++------
src/libbiji/provider/biji-memo-provider.c | 3 +--
8 files changed, 30 insertions(+), 24 deletions(-)
---
diff --git a/src/bjb-bijiben.c b/src/bjb-bijiben.c
index 2ba9c84..98c6931 100644
--- a/src/bjb-bijiben.c
+++ b/src/bjb-bijiben.c
@@ -358,7 +358,6 @@ bijiben_application_local_command_line (GApplication *application,
GError *error = NULL;
gint argc = 0;
gchar **argv = NULL;
- *exit_status = EXIT_SUCCESS;
const GOptionEntry options[] = {
{ "version", 0, 0, G_OPTION_ARG_NONE, &version,
@@ -370,6 +369,8 @@ bijiben_application_local_command_line (GApplication *application,
{ NULL }
};
+ *exit_status = EXIT_SUCCESS;
+
context = g_option_context_new (NULL);
g_option_context_set_summary (context,
_("Take notes and export them everywhere."));
diff --git a/src/bjb-import-dialog.c b/src/bjb-import-dialog.c
index 22881be..388a970 100644
--- a/src/bjb-import-dialog.c
+++ b/src/bjb-import-dialog.c
@@ -382,8 +382,6 @@ add_application (const gchar *app,
static void
bjb_import_dialog_constructed (GObject *obj)
{
- G_OBJECT_CLASS(bjb_import_dialog_parent_class)->constructed(obj);
-
GtkWidget *area, *label_box, *label, *frame;
gchar *path;
GList *windows;
@@ -393,6 +391,8 @@ bjb_import_dialog_constructed (GObject *obj)
GtkWindow *win = GTK_WINDOW (obj);
BjbImportDialogPrivate *priv = self->priv;
+ G_OBJECT_CLASS(bjb_import_dialog_parent_class)->constructed(obj);
+
/* Don't finalize locations with HashTable
* They belong to qdata in gtkwidgets */
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 49e7f4c..9cadd85 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -1069,8 +1069,10 @@ bjb_main_toolbar_constructed (GObject *obj)
static void
bjb_main_toolbar_init (BjbMainToolbar *self)
{
+ BjbMainToolbarPrivate *priv;
+
self->priv = BJB_MAIN_TOOLBAR_GET_PRIVATE(self);
- BjbMainToolbarPrivate *priv = self->priv;
+ priv = self->priv;
priv->type = BJB_TOOLBAR_0 ;
diff --git a/src/libbiji/biji-manager.c b/src/libbiji/biji-manager.c
index 6ae7257..e1cb4b9 100644
--- a/src/libbiji/biji-manager.c
+++ b/src/libbiji/biji-manager.c
@@ -440,16 +440,16 @@ title_is_unique (BijiManager *manager, gchar *title)
gchar *
biji_manager_get_unique_title (BijiManager *manager, const gchar *title)
{
+ gchar *new_title;
+ gint suffix = 2;
+
if (!manager)
return g_strdup (title);
- gchar *new_title;
-
if (!title)
title = "";
new_title = g_strdup (title);
- gint suffix = 2;
while (!title_is_unique (manager, new_title))
{
diff --git a/src/libbiji/biji-note-obj.c b/src/libbiji/biji-note-obj.c
index 968497e..c25de6c 100644
--- a/src/libbiji/biji-note-obj.c
+++ b/src/libbiji/biji-note-obj.c
@@ -287,9 +287,11 @@ biji_note_obj_is_trashed (BijiNoteObj *self)
static const gchar *
biji_note_obj_get_path (BijiItem *item)
{
+ BijiNoteObj *note;
+
g_return_val_if_fail (BIJI_IS_NOTE_OBJ (item), NULL);
- BijiNoteObj *note = BIJI_NOTE_OBJ (item);
+ note = BIJI_NOTE_OBJ (item);
return biji_note_id_get_path (note->priv->id);
}
@@ -536,10 +538,12 @@ biji_note_obj_add_notebook (BijiItem *item,
static gboolean
biji_note_obj_remove_notebook (BijiItem *item, BijiItem *notebook)
{
+ BijiNoteObj *note;
+
g_return_val_if_fail (BIJI_IS_NOTE_OBJ (item), FALSE);
g_return_val_if_fail (BIJI_IS_NOTEBOOK (notebook), FALSE);
- BijiNoteObj *note = BIJI_NOTE_OBJ (item);
+ note = BIJI_NOTE_OBJ (item);
if (g_hash_table_remove (note->priv->labels, biji_item_get_title (notebook)))
{
@@ -598,11 +602,11 @@ biji_note_obj_save_note (BijiNoteObj *self)
gchar *
biji_note_obj_get_icon_file (BijiNoteObj *note)
{
- g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL);
-
const gchar *uuid;
gchar *basename, *filename;
+ g_return_val_if_fail (BIJI_IS_NOTE_OBJ (note), NULL);
+
uuid = BIJI_NOTE_OBJ_GET_CLASS (note)->get_basename (note);
basename = biji_str_mass_replace (uuid, ".note", ".png", ".txt", ".png", NULL);
diff --git a/src/libbiji/editor/biji-webkit-editor.c b/src/libbiji/editor/biji-webkit-editor.c
index 440de5b..6e96d93 100644
--- a/src/libbiji/editor/biji-webkit-editor.c
+++ b/src/libbiji/editor/biji-webkit-editor.c
@@ -1,16 +1,16 @@
/* biji-webkit-editor.c
* Copyright (C) Pierre-Yves LUYTEN 2012 <py luyten fr>
- *
+ *
* bijiben is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* bijiben is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -227,14 +227,16 @@ void
biji_webkit_editor_set_font (BijiWebkitEditor *self, gchar *font)
{
PangoFontDescription *font_desc;
+ const gchar *family;
+ gint size;
/* parse : but we only parse font properties we'll be able
* to transfer to webkit editor
* Maybe is there a better way than webkitSettings,
* eg applying format to the whole body */
font_desc = pango_font_description_from_string (font);
- const gchar * family = pango_font_description_get_family (font_desc);
- gint size = pango_font_description_get_size (font_desc);
+ family = pango_font_description_get_family (font_desc);
+ size = pango_font_description_get_size (font_desc);
if (!pango_font_description_get_size_is_absolute (font_desc))
size /= PANGO_SCALE;
diff --git a/src/libbiji/provider/biji-import-provider.c b/src/libbiji/provider/biji-import-provider.c
index f56aca5..d064b62 100644
--- a/src/libbiji/provider/biji-import-provider.c
+++ b/src/libbiji/provider/biji-import-provider.c
@@ -72,6 +72,10 @@ instanciate_note (BijiImportProvider *self, GFileInfo *info, GFile *container)
gchar *path;
GdkRGBA *color;
BijiManager *manager;
+ GError *error = NULL;
+ BijiInfoSet *set;
+ gchar *html = NULL;
+ GList *notebooks = NULL;
retval = NULL;
@@ -86,12 +90,6 @@ instanciate_note (BijiImportProvider *self, GFileInfo *info, GFile *container)
/* Deserialize it */
-
- GError *error = NULL;
- BijiInfoSet *set;
- gchar *html = NULL;
- GList *notebooks = NULL;
-
biji_tomboy_reader_read (path,
&error,
&set,
diff --git a/src/libbiji/provider/biji-memo-provider.c b/src/libbiji/provider/biji-memo-provider.c
index 14f89d9..fa0540f 100644
--- a/src/libbiji/provider/biji-memo-provider.c
+++ b/src/libbiji/provider/biji-memo-provider.c
@@ -442,8 +442,7 @@ on_client_connected (GObject *obj,
GAsyncResult *res,
gpointer user_data)
{
- GError *error;
- error = NULL;
+ GError *error = NULL;
gchar *query;
BijiMemoProvider *self = BIJI_MEMO_PROVIDER (user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]