8000 Fix clang warnings by sidt4 · Pull Request #842 · PackageKit/PackageKit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix clang warnings #842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/pk-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ main (int argc, char *argv[])
{ "allow-untrusted", '\0', 0, G_OPTION_ARG_NONE, &allow_untrusted,
/* command line argument, do we ask questions */
_("Allow untrusted packages to be installed."), NULL },
{ NULL}
G_OPTION_ENTRY_NULL
};

setlocale (LC_ALL, "");
Expand Down
2 changes: 1 addition & 1 deletion client/pk-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ main (int argc, char *argv[])
const GOptionEntry options[] = {
{ "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
_("Show the program version and exit"), NULL},
{ NULL}
G_OPTION_ENTRY_NULL
};

setlocale (LC_ALL, "");
Expand Down
2 changes: 1 addition & 1 deletion contrib/gstreamer-plugin/pk-gstreamer-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ main (int argc, gchar **argv)
{ "interaction", '\0', 0, G_OPTION_ARG_STRING, &interaction, "Interaction mode specifying which UI elements should be shown", NULL },
{ "startup-notification-id", '\0', 0, G_OPTION_ARG_STRING, &startup_id, "The startup notification ID for focus stealing prevention", NULL },
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &codecs, "GStreamer install infos", NULL },
{ NULL }
G_OPTION_ENTRY_NULL
};

gst_init (&argc, &argv);
Expand Down
6 changes: 2 additions & 4 deletions lib/packagekit-glib2/pk-bitfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ gint
pk_bitfield_contain_priority (PkBitfield values, gint value, ...)
{
va_list args;
guint i;
gint value_temp;
gint retval = -1;

Expand All @@ -59,7 +58,7 @@ pk_bitfield_contain_priority (PkBitfield values, gint value, ...)

/* process the valist */
va_start (args, value);
for (i = 0;; i++) {
while (TRUE) {
value_temp = va_arg (args, gint);
/* do we have this one? */
if (pk_bitfield_contain (values, value_temp)) {
Expand Down Expand Up @@ -90,7 +89,6 @@ PkBitfield
pk_bitfield_from_enums (gint value, ...)
{
va_list args;
guint i;
gint value_temp;
PkBitfield values;

Expand All @@ -99,7 +97,7 @@ pk_bitfield_from_enums (gint value, ...)

/* process the valist */
va_start (args, value);
for (i = 0;; i++) {
while (TRUE) {
value_temp = va_arg (args, gint);
if (value_temp == -1)
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/packagekit-glib2/pk-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pk_debug_pre_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &_verbose,
/* TRANSLATORS: turn on all debugging */
N_("Show debugging information for all files"), NULL },
{ NULL}
G_OPTION_ENTRY_NULL
};

/* add main entry */
Expand Down
63 changes: 40 additions & 23 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pkg = import('pkgconfig')

source_root = meson.project_source_root()

glib_dep = dependency('glib-2.0', version: '>=2.62')
glib_dep = dependency('glib-2.0', version: '>=2.70')
gobject_dep = dependency('gobject-2.0')
gio_dep = dependency('gio-2.0')
gio_unix_dep = dependency('gio-unix-2.0', version: '>=2.16.1')
Expand Down Expand Up @@ -103,8 +103,32 @@ package_data_dir = get_option('datadir')
package_locale_dir = join_paths(get_option('prefix'), get_option('datadir'), 'locale')
pk_plugin_dir = join_paths(get_option('prefix'), get_option('libdir'), 'packagekit-backend')

# maintainer mode is even stricter
if get_option('maintainer')
maintainer_compiler_flags = [
'-Werror',
'-Wall',
'-Wextra',
'-Wcast-align',
'-Wno-uninitialized',
'-Wempty-body',
'-Winit-self',
'-Wnull-dereference',
'-Wfloat-equal',
'-Winline',
'-Wno-error=comment',
]

supported_maintainer_flags = cc.get_supported_arguments(maintainer_compiler_flags, checked: 'warn')

add_project_arguments(
supported_maintainer_flags,
language: ['c', 'cpp']
)
endif

# default compiler flags for C and C++
add_project_arguments(
default_compiler_flags = [
'-Wcast-align',
'-Wno-uninitialized',
'-Werror=missing-declarations',
Expand All @@ -128,11 +152,24 @@ add_project_arguments(
'-Wno-error=unused-parameter',
'-Werror=misleading-indentation',
'-Werror=return-type',
'-Werror=format-security',
['-Werror=format-security', '-Wformat'],
'-Werror=missing-declarations',
'-Werror=pointer-arith',
'-Werror=empty-body',
]

supported_compiler_flags = []
foreach arg: default_compiler_flags
if cc.has_multi_arguments(arg)
supported_compiler_flags += arg
endif
endforeach


# if a common compiler flag is not supported by 'c', then it should
# apply to c++ too. So, we don't need a double check here.
add_project_arguments(
supported_compiler_flags,
language: ['c', 'cpp']
)

Expand Down Expand Up @@ -162,26 +199,6 @@ add_project_arguments(
language: 'cpp'
)

# maintainer mode is even stricter
if get_option('maintainer')
add_project_arguments(
'-Werror',
'-Wall',
'-Wextra',
'-Wcast-align',
'-Wno-uninitialized',
'-Wempty-body',
'-Winit-self',
'-Wnull-dereference',
'-Wfloat-equal',
'-Winline',
'-Wno-error=comment',
'-Werror=format-security',

language: ['c', 'cpp']
)
endif

subdir('po')
subdir('policy')
subdir('etc')
Expand Down
3 changes: 1 addition & 2 deletions src/pk-backend-spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ pk_backend_spawn_va_list_to_argv (const gchar *string_first, va_list *args)
{
GPtrArray *ptr_array;
gchar *value_temp;
guint i;

g_return_val_if_fail (args != NULL, NULL);
g_return_val_if_fail (string_first != NULL, NULL);
Expand All @@ -823,7 +822,7 @@ pk_backend_spawn_va_list_to_argv (const gchar *string_first, va_list *args)
g_ptr_array_add (ptr_array, g_strdup (string_first));

/* process all the va_list entries */
for (i = 0;; i++) {
while (TRUE) {
value_temp = va_arg (*args, gchar *);
if (value_temp == NULL)
break;
Expand Down
2 changes: 1 addition & 1 deletion src/pk-direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ main (int argc, char *argv[])
{ "backend", '\0', 0, G_OPTION_ARG_STRING, &backend_name,
/* TRANSLATORS: a backend is the system package tool, e.g. dnf, apt */
_("Packaging backend to use, e.g. dummy"), NULL },
{ NULL }
G_OPTION_ENTRY_NULL
};

setlocale (LC_ALL, "");
Expand Down
2 changes: 1 addition & 1 deletion src/pk-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ main (int argc, char *argv[])
{ "keep-environment", '\0', 0, G_OPTION_ARG_NONE, &keep_environment,
/* TRANSLATORS: don't unset environment variables, used for debugging */
_("Don't clear environment on startup"), NULL },
{ NULL }
G_OPTION_ENTRY_NULL
};

setlocale (LC_ALL, "");
Expand Down
6 changes: 0 additions & 6 deletions src/pk-scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,9 +855,7 @@ pk_scheduler_get_state (PkScheduler *scheduler)
{
guint i;
guint length;
guint running = 0;
guint waiting = 0;
guint no_commit = 0;
PkRoleEnum role;
PkSchedulerItem *item;
PkTransactionState state;
Expand All @@ -872,12 +870,8 @@ pk_scheduler_get_state (PkScheduler *scheduler)
for (i = 0; i < length; i++) {
item = (PkSchedulerItem *) g_ptr_array_index (scheduler->priv->array, i);
state = pk_transaction_get_state (item->transaction);
if (state == PK_TRANSACTION_STATE_RUNNING)
running++;
if (state == PK_TRANSACTION_STATE_READY)
waiting++;
if (state == PK_TRANSACTION_STATE_NEW)
no_commit++;

role = pk_transaction_get_role (item->transaction);
g_string_append_printf (string, "%0i\t%s\t%s\tstate[%s] "
Expand Down
0