mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +08:00
cLib: Enable all warnings and treat them as errors
They are useful! missing-field-initializiers has been disabled as libgit2's standard way of initializing the options gives this error.
This commit is contained in:
@ -45,6 +45,8 @@ add_library(native-lib
|
||||
git.c
|
||||
)
|
||||
|
||||
target_compile_options(native-lib PRIVATE -Werror -Wall -Wextra -Wno-missing-field-initializers)
|
||||
|
||||
# The order of these libraries is super dooper important
|
||||
# Otherwise you'll get linker errors
|
||||
target_link_libraries(native-lib git2-lib ssh2-lib openssl-lib crypto-lib android log)
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#include "gitjournal.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
void gj_log(const char *message) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GitJournalLib", "%s", message);
|
||||
}
|
||||
@ -31,6 +33,10 @@ JNIEXPORT void JNICALL
|
||||
Java_io_gitjournal_gitjournal_Git_setupLib(
|
||||
JNIEnv *env,
|
||||
jobject this_obj) {
|
||||
|
||||
UNUSED(env);
|
||||
UNUSED(this_obj);
|
||||
|
||||
gj_init();
|
||||
}
|
||||
|
||||
@ -39,6 +45,8 @@ Java_io_gitjournal_gitjournal_Git_init(
|
||||
JNIEnv *env,
|
||||
jobject this_obj,
|
||||
jstring jni_git_base_path) {
|
||||
UNUSED(this_obj);
|
||||
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
|
||||
int err = gj_git_init(git_base_path);
|
||||
@ -56,6 +64,7 @@ Java_io_gitjournal_gitjournal_Git_clone(
|
||||
jobject this_obj,
|
||||
jstring jni_clone_url,
|
||||
jstring jni_git_base_path) {
|
||||
UNUSED(this_obj);
|
||||
const char *clone_url = (*env)->GetStringUTFChars(env, jni_clone_url, 0);
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
|
||||
@ -76,6 +85,7 @@ Java_io_gitjournal_gitjournal_Git_pull(
|
||||
jstring jni_git_base_path,
|
||||
jstring jni_author_name,
|
||||
jstring jni_author_email) {
|
||||
UNUSED(this_obj);
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
const char *author_name = (*env)->GetStringUTFChars(env, jni_author_name, 0);
|
||||
const char *author_email = (*env)->GetStringUTFChars(env, jni_author_email, 0);
|
||||
@ -95,6 +105,7 @@ Java_io_gitjournal_gitjournal_Git_push(
|
||||
JNIEnv *env,
|
||||
jobject this_obj,
|
||||
jstring jni_git_base_path) {
|
||||
UNUSED(this_obj);
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
|
||||
int err = gj_git_push(git_base_path);
|
||||
@ -114,6 +125,7 @@ Java_io_gitjournal_gitjournal_Git_commit(
|
||||
jstring jni_author_name,
|
||||
jstring jni_author_email,
|
||||
jstring jni_message) {
|
||||
UNUSED(this_obj);
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
const char *author_name = (*env)->GetStringUTFChars(env, jni_author_name, 0);
|
||||
const char *author_email = (*env)->GetStringUTFChars(env, jni_author_email, 0);
|
||||
@ -134,6 +146,7 @@ Java_io_gitjournal_gitjournal_Git_resetHard(
|
||||
jobject this_obj,
|
||||
jstring jni_git_base_path,
|
||||
jstring jni_ref) {
|
||||
UNUSED(this_obj);
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
const char *ref = (*env)->GetStringUTFChars(env, jni_ref, 0);
|
||||
|
||||
@ -152,6 +165,8 @@ Java_io_gitjournal_gitjournal_Git_add(
|
||||
jobject this_obj,
|
||||
jstring jni_git_base_path,
|
||||
jstring jni_add_pattern) {
|
||||
UNUSED(this_obj);
|
||||
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
const char *add_pattern = (*env)->GetStringUTFChars(env, jni_add_pattern, 0);
|
||||
|
||||
@ -171,6 +186,8 @@ Java_io_gitjournal_gitjournal_Git_rm(
|
||||
jobject this_obj,
|
||||
jstring jni_git_base_path,
|
||||
jstring jni_pattern) {
|
||||
UNUSED(this_obj);
|
||||
|
||||
const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
|
||||
const char *pattern = (*env)->GetStringUTFChars(env, jni_pattern, 0);
|
||||
|
||||
@ -191,6 +208,8 @@ Java_io_gitjournal_gitjournal_Git_setSshKeys(
|
||||
jstring jni_public_key_path,
|
||||
jstring jni_private_key_path,
|
||||
jstring jni_passphrase) {
|
||||
UNUSED(this_obj);
|
||||
|
||||
const char *public_key_path = (*env)->GetStringUTFChars(env, jni_public_key_path, 0);
|
||||
const char *private_key_path = (*env)->GetStringUTFChars(env, jni_private_key_path, 0);
|
||||
const char *passphrase = (*env)->GetStringUTFChars(env, jni_passphrase, 0);
|
||||
@ -205,6 +224,8 @@ Java_io_gitjournal_gitjournal_Git_generateKeys(
|
||||
jstring jni_private_key_path,
|
||||
jstring jni_public_key_path,
|
||||
jstring jni_comment) {
|
||||
UNUSED(this_obj);
|
||||
|
||||
const char *private_key_path = (*env)->GetStringUTFChars(env, jni_private_key_path, 0);
|
||||
const char *public_key_path = (*env)->GetStringUTFChars(env, jni_public_key_path, 0);
|
||||
const char *comment = (*env)->GetStringUTFChars(env, jni_comment, 0);
|
||||
|
@ -13,6 +13,8 @@
|
||||
#define GJ_ERR_PULL_INVALID_STATE -955
|
||||
#define GJ_ERR_LAST -955
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
void gj_log_internal(const char *format, ...)
|
||||
{
|
||||
char buffer[1024];
|
||||
@ -73,6 +75,9 @@ void gj_error_free(const gj_error *err)
|
||||
|
||||
int match_cb(const char *path, const char *spec, void *payload)
|
||||
{
|
||||
UNUSED(spec);
|
||||
UNUSED(payload);
|
||||
|
||||
gj_log_internal("Match: %s\n", path);
|
||||
return 0;
|
||||
}
|
||||
@ -111,6 +116,9 @@ cleanup:
|
||||
|
||||
int rm_match_cb(const char *path, const char *spec, void *payload)
|
||||
{
|
||||
UNUSED(spec);
|
||||
UNUSED(payload);
|
||||
|
||||
char *git_base_path = (char *)payload;
|
||||
if (!git_base_path)
|
||||
{
|
||||
@ -155,7 +163,6 @@ int gj_git_rm(const char *git_base_path, const char *pattern)
|
||||
char *paths[] = {(char *)pattern};
|
||||
git_strarray pathspec = {paths, 1};
|
||||
|
||||
void *payload = (void *)git_base_path;
|
||||
err = git_index_remove_all(index, &pathspec, rm_match_cb, (void *)git_base_path);
|
||||
if (err < 0)
|
||||
goto cleanup;
|
||||
@ -291,6 +298,8 @@ cleanup:
|
||||
|
||||
int fetch_progress(const git_transfer_progress *stats, void *payload)
|
||||
{
|
||||
UNUSED(payload);
|
||||
|
||||
int fetch_percent =
|
||||
(100 * stats->received_objects) /
|
||||
stats->total_objects;
|
||||
@ -327,6 +336,8 @@ typedef struct
|
||||
int credentials_cb(git_cred **out, const char *url, const char *username_from_url,
|
||||
unsigned int allowed_types, void *payload)
|
||||
{
|
||||
UNUSED(url);
|
||||
|
||||
if (!payload)
|
||||
{
|
||||
gj_log_internal("credentials_cb has no payload\n");
|
||||
@ -399,7 +410,6 @@ int gj_git_push(const char *git_base_path)
|
||||
int err = 0;
|
||||
git_repository *repo = NULL;
|
||||
git_remote *remote = NULL;
|
||||
git_oid head_id;
|
||||
|
||||
err = git_repository_open(&repo, git_base_path);
|
||||
if (err < 0)
|
||||
@ -433,8 +443,8 @@ cleanup:
|
||||
static int perform_fastforward(git_repository *repo, const git_oid *target_oid)
|
||||
{
|
||||
git_checkout_options ff_checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
git_reference *target_ref;
|
||||
git_reference *new_target_ref;
|
||||
git_reference *target_ref = NULL;
|
||||
git_reference *new_target_ref = NULL;
|
||||
git_object *target = NULL;
|
||||
int err = 0;
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <libssh/callbacks.h>
|
||||
*/
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
void change_pubickey_comment(const char *filename, const char *comment)
|
||||
{
|
||||
FILE *fp = fopen(filename, "r");
|
||||
@ -33,6 +35,7 @@ void change_pubickey_comment(const char *filename, const char *comment)
|
||||
|
||||
void gj_ssh_log_callback(int priority, const char *function, const char *buffer, void *userdata)
|
||||
{
|
||||
UNUSED(userdata);
|
||||
char log_str[1024];
|
||||
sprintf(log_str, "LIB_SSH P%d : %s : %s\n", priority, function, buffer);
|
||||
gj_log(log_str);
|
||||
@ -41,6 +44,10 @@ void gj_ssh_log_callback(int priority, const char *function, const char *buffer,
|
||||
int gj_generate_ssh_keys(const char *private_key_path,
|
||||
const char *public_key_path, const char *comment)
|
||||
{
|
||||
UNUSED(private_key_path);
|
||||
UNUSED(public_key_path);
|
||||
UNUSED(comment);
|
||||
|
||||
return 1;
|
||||
/*
|
||||
ssh_key key;
|
||||
|
Reference in New Issue
Block a user