static void one_test(grpc_channel_args *args, char *expected_error_message) { grpc_channel *chan = grpc_insecure_channel_create("nonexistant:54321", args, NULL); verify_last_error(expected_error_message); gpr_free(expected_error_message); grpc_channel_destroy(chan); }
int git_filebuf_hash(git_oid *oid, git_filebuf *file) { assert(oid && file && file->digest); flush_buffer(file); if (verify_last_error(file) < 0) return -1; git_hash_final(oid, file->digest); git_hash_free_ctx(file->digest); file->digest = NULL; return 0; }
int git_filebuf_commit(git_filebuf *file, mode_t mode) { /* temporary files cannot be committed */ assert(file && file->path_original); file->flush_mode = Z_FINISH; flush_buffer(file); if (verify_last_error(file) < 0) goto on_error; file->fd_is_open = false; if (p_close(file->fd) < 0) { giterr_set(GITERR_OS, "Failed to close file at '%s'", file->path_lock); goto on_error; } file->fd = -1; if (p_chmod(file->path_lock, mode)) { giterr_set(GITERR_OS, "Failed to set attributes for file at '%s'", file->path_lock); goto on_error; } p_unlink(file->path_original); if (p_rename(file->path_lock, file->path_original) < 0) { giterr_set(GITERR_OS, "Failed to rename lockfile to '%s'", file->path_original); goto on_error; } git_filebuf_cleanup(file); return 0; on_error: git_filebuf_cleanup(file); return -1; }