Skip to content

Commit

Permalink
zypp: Use 'G_GNUC_PRINTF' attribute to 'zypp_backend_finished_error' …
Browse files Browse the repository at this point in the history
…and fixup warnings

Add 'G_GNUC_PRINTF' attribute to fix the following warning:

../backends/zypp/pk-backend-zypp.cpp: In function ‘void zypp_backend_finished_error(PkBackendJob*, PkErrorEnum, const char*, ...)’:
../backends/zypp/pk-backend-zypp.cpp:1803:35: warning: function ‘void zypp_backend_finished_error(PkBackendJob*, PkErrorEnum, const char*, ...)’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
 1803 |         buffer = g_strdup_vprintf (format, args);
      |                  ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

and fix follow up warnings due to that.

pk-backend-zypp.cpp:1933:53: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:2131:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:2135:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:2215:53: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:2597:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:2869:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:2985:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:2989:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:3279:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:3283:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:3334:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:3338:45: warning: format not a string literal and no format arguments [-Wformat-security]
pk-backend-zypp.cpp:3961:45: warning: format not a string literal and no format arguments [-Wformat-security]

Closes PackageKit#692
  • Loading branch information
sidt4 committed Sep 12, 2024
1 parent 1fabb7a commit 8a62a9c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions backends/zypp/pk-backend-zypp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,7 @@ zypp_refresh_cache (PkBackendJob *job, ZYpp::Ptr zypp, gboolean force)
/**
* helper to simplify returning errors
*/
G_GNUC_PRINTF (3, 4)
static void
zypp_backend_finished_error (PkBackendJob *job, PkErrorEnum err_code,
const char *format, ...)
Expand Down Expand Up @@ -1931,7 +1932,7 @@ backend_required_by_thread (PkBackendJob *job, GVariant *params, gpointer user_d
}
zypp_backend_finished_error (
job, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED,
problem.c_str());
"%s", problem.c_str());
return;
}

Expand Down Expand Up @@ -2128,11 +2129,11 @@ backend_depends_on_thread (PkBackendJob *job, GVariant *params, gpointer user_da
pk_backend_job_set_percentage (job, 100);
} catch (const repo::RepoNotFoundException &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str());
job, PK_ERROR_ENUM_REPO_NOT_FOUND, "%s", ex.asUserString().c_str());
return;
} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str());
job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", ex.asUserString().c_str());
return;
}
}
Expand Down Expand Up @@ -2212,7 +2213,7 @@ backend_get_details_thread (PkBackendJob *job, GVariant *params, gpointer user_d
(gulong)size);
} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", ex.asUserString ().c_str ());
return;
}
}
Expand Down Expand Up @@ -2594,7 +2595,7 @@ backend_install_files_thread (PkBackendJob *job, GVariant *params, gpointer user

} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", ex.asUserString ().c_str ());
return;
}

Expand Down Expand Up @@ -2866,7 +2867,7 @@ backend_install_packages_thread (PkBackendJob *job, GVariant *params, gpointer u

} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str());
job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", ex.asUserString().c_str());
return;
}
}
Expand Down Expand Up @@ -2982,11 +2983,11 @@ backend_remove_packages_thread (PkBackendJob *job, GVariant *params, gpointer us

} catch (const repo::RepoNotFoundException &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str());
job, PK_ERROR_ENUM_REPO_NOT_FOUND, "%s", ex.asUserString().c_str());
return;
} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str());
job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", ex.asUserString().c_str());
return;
}
}
Expand Down Expand Up @@ -3276,11 +3277,11 @@ pk_backend_get_repo_list (PkBackend *backend, PkBackendJob *job, PkBitfield filt
repos = list<RepoInfo>(manager.repoBegin(),manager.repoEnd());
} catch (const repo::RepoNotFoundException &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str());
job, PK_ERROR_ENUM_REPO_NOT_FOUND, "%s", ex.asUserString().c_str());
return;
} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str());
job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", ex.asUserString().c_str());
return;
}

Expand Down Expand Up @@ -3331,11 +3332,11 @@ pk_backend_repo_enable (PkBackend *backend, PkBackendJob *job, const gchar *rid,

} catch (const repo::RepoNotFoundException &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str());
job, PK_ERROR_ENUM_REPO_NOT_FOUND, "%s", ex.asUserString().c_str());
return;
} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str());
job, PK_ERROR_ENUM_INTERNAL_ERROR, "%s", ex.asUserString().c_str());
return;
}

Expand Down Expand Up @@ -3953,7 +3954,7 @@ backend_download_packages_thread (PkBackendJob *job, GVariant *params, gpointer
}
} catch (const Exception &ex) {
zypp_backend_finished_error (
job, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, ex.asUserString().c_str());
job, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, "%s", ex.asUserString().c_str());
return;
}
}
Expand Down

0 comments on commit 8a62a9c

Please sign in to comment.