Skip to content

Commit 85d1f15

Browse files
authored
Merge pull request #354 from darealshinji/patch-1
avoid unneeded if-statements, initializer fixes
2 parents af2f5ae + 66db303 commit 85d1f15

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

appimagetool.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ gchar* get_desktop_entry(GKeyFile *kf, char *key) {
204204
* line is large enough to hold the resulting string*/
205205
static void replacestr(char *line, const char *search, const char *replace)
206206
{
207-
char *sp;
207+
char *sp = NULL;
208208

209209
if ((sp = strstr(line, search)) == NULL) {
210210
return;
@@ -236,8 +236,8 @@ static GOptionEntry entries[] =
236236
{ "sign", 's', 0, G_OPTION_ARG_NONE, &sign, "Sign with gpg2", NULL },
237237
{ "comp", 0, 0, G_OPTION_ARG_STRING, &sqfs_comp, "Squashfs compression", NULL },
238238
{ "no-appstream", 'n', 0, G_OPTION_ARG_NONE, &no_appstream, "Do not check AppStream metadata", NULL },
239-
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &remaining_args, NULL },
240-
{ NULL }
239+
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &remaining_args, NULL, NULL },
240+
{ 0,0,0,0,0,0,0 }
241241
};
242242

243243
int
@@ -400,7 +400,7 @@ main (int argc, char *argv[])
400400
fprintf (stdout, "%s should be packaged as %s\n", source, destination);
401401
/* Check if the Icon file is how it is expected */
402402
gchar* icon_name = get_desktop_entry(kf, "Icon");
403-
gchar* icon_file_path;
403+
gchar* icon_file_path = NULL;
404404
gchar* icon_file_png;
405405
gchar* icon_file_svg;
406406
gchar* icon_file_svgz;
@@ -409,15 +409,15 @@ main (int argc, char *argv[])
409409
icon_file_svg = g_strdup_printf("%s/%s.svg", source, icon_name);
410410
icon_file_svgz = g_strdup_printf("%s/%s.svgz", source, icon_name);
411411
icon_file_xpm = g_strdup_printf("%s/%s.xpm", source, icon_name);
412-
if(g_file_test(icon_file_png, G_FILE_TEST_IS_REGULAR))
412+
if (g_file_test(icon_file_png, G_FILE_TEST_IS_REGULAR)) {
413413
icon_file_path = icon_file_png;
414-
if(g_file_test(icon_file_svg, G_FILE_TEST_IS_REGULAR))
414+
} else if(g_file_test(icon_file_svg, G_FILE_TEST_IS_REGULAR)) {
415415
icon_file_path = icon_file_svg;
416-
if(g_file_test(icon_file_svgz, G_FILE_TEST_IS_REGULAR))
416+
} else if(g_file_test(icon_file_svgz, G_FILE_TEST_IS_REGULAR)) {
417417
icon_file_path = icon_file_svgz;
418-
if(g_file_test(icon_file_xpm, G_FILE_TEST_IS_REGULAR))
418+
} else if(g_file_test(icon_file_xpm, G_FILE_TEST_IS_REGULAR)) {
419419
icon_file_path = icon_file_xpm;
420-
if (! g_file_test(icon_file_path, G_FILE_TEST_IS_REGULAR)){
420+
} else {
421421
fprintf (stderr, "%s{.png,.svg,.svgz,.xpm} not present but defined in desktop file\n", icon_name);
422422
exit(1);
423423
}
@@ -548,10 +548,10 @@ main (int argc, char *argv[])
548548
unsigned long ui_offset = 0;
549549
unsigned long ui_length = 0;
550550
get_elf_section_offset_and_lenghth(destination, ".upd_info", &ui_offset, &ui_length);
551-
if(verbose)
551+
if(verbose) {
552552
printf("ui_offset: %lu\n", ui_offset);
553-
if(verbose)
554553
printf("ui_length: %lu\n", ui_length);
554+
}
555555
if(ui_offset == 0) {
556556
die("Could not determine offset for updateinformation");
557557
} else {
@@ -617,10 +617,10 @@ main (int argc, char *argv[])
617617
unsigned long sig_offset = 0;
618618
unsigned long sig_length = 0;
619619
get_elf_section_offset_and_lenghth(destination, ".sha256_sig", &sig_offset, &sig_length);
620-
if(verbose)
620+
if(verbose) {
621621
printf("sig_offset: %lu\n", sig_offset);
622-
if(verbose)
623622
printf("sig_length: %lu\n", sig_length);
623+
}
624624
if(sig_offset == 0) {
625625
die("Could not determine offset for signature");
626626
} else {

0 commit comments

Comments
 (0)