/*
* panel-modules.c
*
* Copyright (C) 2010 Vincent Untz <vuntz@gnome.org>
*
* This program 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 2 of the
* License, or (at your option) any later version.
*
* This program 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* Authors:
* Vincent Untz <vuntz@gnome.org>
*/
#include <config.h>
#include <gio/gio.h>
#include <libcafe-panel-applet-private/panel-applets-manager-dbus.h>
#include "panel-applets-manager.h"
#include "panel-modules.h"
static void
panel_modules_ensure_extension_points_registered (void)
{
static gboolean registered_extensions = FALSE;
GIOExtensionPoint *ep;<--- The scope of the variable 'ep' can be reduced. [+]The scope of the variable 'ep' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
if (!registered_extensions) {
registered_extensions = TRUE;
ep = g_io_extension_point_register (CAFE_PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME);
g_io_extension_point_set_required_type (ep, PANEL_TYPE_APPLETS_MANAGER);
}
}
void
panel_modules_ensure_loaded (void)
{
static gboolean loaded_dirs = FALSE;
const char *module_path;<--- The scope of the variable 'module_path' can be reduced. [+]The scope of the variable 'module_path' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x)
{
int i = 0;
if (x) {
// it's safe to move 'int i = 0;' here
for (int n = 0; n < 10; ++n) {
// it is possible but not safe to move 'int i = 0;' here
do_something(&i);
}
}
}
When you see this message it is always safe to reduce the variable scope 1 level.
panel_modules_ensure_extension_points_registered ();
if (!loaded_dirs) {
GList *modules;
loaded_dirs = TRUE;
/* We load the modules explicitly instead of using scan_all
* so that we can leak a reference to them. This prevents them
* from getting unloaded later (something they aren't designed
* to cope with) */
modules = g_io_modules_load_all_in_directory (PANEL_MODULES_DIR);
g_list_free (modules);
module_path = g_getenv ("CAFE_PANEL_EXTRA_MODULES");
if (module_path) {
gchar **paths;
int i;
paths = g_strsplit (module_path, ":", 0);
for (i = 0; paths[i] != NULL; i++) {
modules = g_io_modules_load_all_in_directory (paths[i]);
g_list_free (modules);
}
g_strfreev (paths);
}
cafe_panel_applets_manager_dbus_get_type ();
}
}