@@ -123,7 +123,7 @@ int sfs_mksquashfs(char *source, char *destination, int offset) {
123123
124124 guint sqfs_opts_len = sqfs_opts ? g_strv_length (sqfs_opts ) : 0 ;
125125
126- int max_num_args = sqfs_opts_len + 22 ;
126+ int max_num_args = ( int ) sqfs_opts_len + 22 ;
127127 char * args [max_num_args ];
128128
129129 int i = 0 ;
@@ -270,9 +270,9 @@ static void replacestr(char *line, const char *search, const char *replace)
270270 if ((sp = strstr (line , search )) == NULL ) {
271271 return ;
272272 }
273- int search_len = strlen (search );
274- int replace_len = strlen (replace );
275- int tail_len = strlen (sp + search_len );
273+ size_t search_len = strlen (search );
274+ size_t replace_len = strlen (replace );
275+ size_t tail_len = strlen (sp + search_len );
276276
277277 memmove (sp + replace_len ,sp + search_len ,tail_len + 1 );
278278 memcpy (sp , replace , replace_len );
@@ -304,6 +304,8 @@ gchar* archToName(fARCH arch) {
304304 case fARCH_x86_64 :
305305 return "x86_64" ;
306306 }
307+ // Should never reach here if all enum values are handled
308+ return "unknown" ;
307309}
308310
309311gchar * getArchName (bool * archs ) {
@@ -464,10 +466,10 @@ bool readFile(char* filename, size_t* size, char** buffer) {
464466 long fsize = ftell (f );
465467 fseek (f , 0 , SEEK_SET );
466468
467- char * indata = malloc (fsize );
468- fread (indata , fsize , 1 , f );
469+ char * indata = malloc (( size_t ) fsize );
470+ fread (indata , ( size_t ) fsize , 1 , f );
469471 fclose (f );
470- * size = (int )fsize ;
472+ * size = (size_t )fsize ;
471473 * buffer = indata ;
472474 return TRUE;
473475}
@@ -694,7 +696,11 @@ main (int argc, char *argv[])
694696 g_spawn_command_line_sync (command_line , & out , NULL , & exit_status , & error );
695697
696698 // g_spawn_command_line_sync might have set error already, in that case we don't want to overwrite
699+ #if GLIB_CHECK_VERSION (2 , 70 , 0 )
700+ if (error != NULL || !g_spawn_check_wait_status (exit_status , & error )) {
701+ #else
697702 if (error != NULL || !g_spawn_check_exit_status (exit_status , & error )) {
703+ #endif
698704 if (error == NULL ) {
699705 g_printerr ("Failed to run 'git rev-parse --short HEAD, but failed to interpret GLib error state: %d\n" , exit_status );
700706 } else {
@@ -776,7 +782,8 @@ main (int argc, char *argv[])
776782 const char * const env_app_name = getenv ("APPIMAGETOOL_APP_NAME" );
777783 if (env_app_name != NULL ) {
778784 fprintf (stderr , "Using user-specified app name: %s\n" , env_app_name );
779- strncpy (app_name_for_filename , env_app_name , PATH_MAX );
785+ strncpy (app_name_for_filename , env_app_name , PATH_MAX - 1 );
786+ app_name_for_filename [PATH_MAX - 1 ] = '\0' ;
780787 } else {
781788 const gchar * const desktop_file_app_name = get_desktop_entry (kf , "Name" );
782789 sprintf (app_name_for_filename , "%s" , desktop_file_app_name );
@@ -797,9 +804,9 @@ main (int argc, char *argv[])
797804
798805 // if $VERSION is specified, we embed it into the filename
799806 if (version_env != NULL ) {
800- sprintf (dest_path , "%s-%s-%s.AppImage" , app_name_for_filename , version_env , arch );
807+ snprintf (dest_path , sizeof ( dest_path ) , "%s-%s-%s.AppImage" , app_name_for_filename , version_env , arch );
801808 } else {
802- sprintf (dest_path , "%s-%s.AppImage" , app_name_for_filename , arch );
809+ snprintf (dest_path , sizeof ( dest_path ) , "%s-%s.AppImage" , app_name_for_filename , arch );
803810 }
804811
805812 destination = strdup (dest_path );
@@ -922,9 +929,9 @@ main (int argc, char *argv[])
922929 }
923930 }
924931 if (verbose )
925- printf ("Size of the embedded runtime: %d bytes\n" , size );
926-
927- int result = sfs_mksquashfs (source , destination , size );
932+ printf ("Size of the embedded runtime: %zu bytes\n" , size );
933+
934+ int result = sfs_mksquashfs (source , destination , ( int ) size );
928935 if (result != 0 )
929936 die ("sfs_mksquashfs error" );
930937
@@ -961,7 +968,7 @@ main (int argc, char *argv[])
961968 int ret = snprintf (buf , sizeof (buf ), "gh-releases-zsync|%s|%s|latest|%s*-%s.AppImage.zsync" , github_repository_owner , github_repository_name , app_name_for_filename , arch );
962969 if (ret < 0 ) {
963970 die ("snprintf error" );
964- } else if (ret >= sizeof (buf )) {
971+ } else if (( size_t ) ret >= sizeof (buf )) {
965972 die ("snprintf buffer overflow" );
966973 }
967974 updateinformation = buf ;
@@ -996,7 +1003,7 @@ main (int argc, char *argv[])
9961003 int ret = snprintf (buf , sizeof (buf ), "gh-releases-zsync|%s|%s|%s|%s*-%s.AppImage.zsync" , parts [0 ], parts [1 ], channel , app_name_for_filename , arch );
9971004 if (ret < 0 ) {
9981005 die ("snprintf error" );
999- } else if (ret >= sizeof (buf )) {
1006+ } else if (( size_t ) ret >= sizeof (buf )) {
10001007 die ("snprintf buffer overflow" );
10011008 }
10021009 updateinformation = buf ;
@@ -1014,7 +1021,7 @@ main (int argc, char *argv[])
10141021 int ret = snprintf (buf , sizeof (buf ), "zsync|%s/-/jobs/artifacts/%s/raw/%s-%s.AppImage.zsync?job=%s" , CI_PROJECT_URL , CI_COMMIT_REF_NAME , app_name_for_filename , arch , CI_JOB_NAME );
10151022 if (ret < 0 ) {
10161023 die ("snprintf error" );
1017- } else if (ret >= sizeof (buf )) {
1024+ } else if (( size_t ) ret >= sizeof (buf )) {
10181025 die ("snprintf buffer overflow" );
10191026 }
10201027 updateinformation = buf ;
@@ -1061,7 +1068,7 @@ main (int argc, char *argv[])
10611068 FILE * fpdst2 = fopen (destination , "r+" );
10621069 if (fpdst2 == NULL )
10631070 die ("Not able to open the destination file for writing, aborting" );
1064- fseek (fpdst2 , ui_offset , SEEK_SET );
1071+ fseek (fpdst2 , ( long ) ui_offset , SEEK_SET );
10651072 // fseek(fpdst2, ui_offset, SEEK_SET);
10661073 // fwrite(0x00, 1, 1024, fpdst); // FIXME: Segfaults; why?
10671074 // fseek(fpdst, ui_offset, SEEK_SET);
@@ -1107,7 +1114,7 @@ main (int argc, char *argv[])
11071114 die ("Failed to open AppImage for updating" );
11081115 }
11091116
1110- if (fseek (destinationfp , digest_md5_offset , SEEK_SET ) != 0 ) {
1117+ if (fseek (destinationfp , ( long ) digest_md5_offset , SEEK_SET ) != 0 ) {
11111118 fclose (destinationfp );
11121119 die ("Failed to embed MD5 digest: could not seek to section offset" );
11131120 }
@@ -1141,7 +1148,7 @@ main (int argc, char *argv[])
11411148
11421149 if (verbose ) {
11431150 fprintf (stderr , "Running zsyncmake process: " );
1144- for (gint j = 0 ; j < (sizeof (zsyncmake_command ) / sizeof (char * ) - 1 ); ++ j ) {
1151+ for (gint j = 0 ; j < (gint )( sizeof (zsyncmake_command ) / sizeof (char * ) - 1 ); ++ j ) {
11451152 fprintf (stderr , "'%s' " , zsyncmake_command [j ]);
11461153 }
11471154 fprintf (stderr , "\n" );
0 commit comments