core-agent-linux: misc const/void fixups

This commit is contained in:
Vincent Penquerc'h 2013-12-30 05:35:46 -05:00 committed by Marek Marczykowski-Górecki
parent 214365e272
commit 9a4b1efa61
8 changed files with 30 additions and 30 deletions

View File

@ -8,12 +8,12 @@
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
static void fix_display() static void fix_display(void)
{ {
setenv("DISPLAY", ":0", 1); setenv("DISPLAY", ":0", 1);
} }
static void produce_message(char * type, const char *fmt, va_list args) static void produce_message(const char * type, const char *fmt, va_list args)
{ {
char *dialog_msg; char *dialog_msg;
char buf[1024]; char buf[1024];

View File

@ -1,4 +1,4 @@
int write_all(int fd, void *buf, int size); int write_all(int fd, const void *buf, int size);
int read_all(int fd, void *buf, int size); int read_all(int fd, void *buf, int size);
int copy_fd_all(int fdout, int fdin); int copy_fd_all(int fdout, int fdin);
void set_nonblock(int fd); void set_nonblock(int fd);

View File

@ -1,6 +1,6 @@
#include "qfile-utils.h" #include "qfile-utils.h"
char *get_abs_path(char *cwd, char *pathname) char *get_abs_path(const char *cwd, const char *pathname)
{ {
char *ret; char *ret;
if (pathname[0] == '/') if (pathname[0] == '/')
@ -9,7 +9,7 @@ char *get_abs_path(char *cwd, char *pathname)
return ret; return ret;
} }
int do_fs_walk(char *file) int do_fs_walk(const char *file)
{ {
char *newfile; char *newfile;
struct stat st; struct stat st;

View File

@ -14,7 +14,7 @@
#define INCOMING_DIR_ROOT "/home/user/QubesIncoming" #define INCOMING_DIR_ROOT "/home/user/QubesIncoming"
int prepare_creds_return_uid(const char *username) int prepare_creds_return_uid(const char *username)
{ {
struct passwd *pwd; const struct passwd *pwd;
pwd = getpwnam(username); pwd = getpwnam(username);
if (!pwd) { if (!pwd) {
perror("getpwnam"); perror("getpwnam");

View File

@ -24,9 +24,9 @@ void notify_progress(int size, int flag)
void do_notify_progress(long long total, int flag) void do_notify_progress(long long total, int flag)
{ {
char *du_size_env = getenv("FILECOPY_TOTAL_SIZE"); const char *du_size_env = getenv("FILECOPY_TOTAL_SIZE");
char *progress_type_env = getenv("PROGRESS_TYPE"); const char *progress_type_env = getenv("PROGRESS_TYPE");
char *saved_stdout_env = getenv("SAVED_FD_1"); const char *saved_stdout_env = getenv("SAVED_FD_1");
if (!progress_type_env) if (!progress_type_env)
return; return;
if (!strcmp(progress_type_env, "console") && du_size_env) { if (!strcmp(progress_type_env, "console") && du_size_env) {
@ -45,7 +45,7 @@ void do_notify_progress(long long total, int flag)
} }
} }
void notify_end_and_wait_for_result() void notify_end_and_wait_for_result(void)
{ {
struct file_header end_hdr; struct file_header end_hdr;
@ -59,13 +59,13 @@ void notify_end_and_wait_for_result()
wait_for_result(); wait_for_result();
} }
int write_all_with_crc(int fd, void *buf, int size) int write_all_with_crc(int fd, const void *buf, int size)
{ {
crc32_sum = Crc32_ComputeBuf(crc32_sum, buf, size); crc32_sum = Crc32_ComputeBuf(crc32_sum, buf, size);
return write_all(fd, buf, size); return write_all(fd, buf, size);
} }
void wait_for_result() void wait_for_result(void)
{ {
struct result_header hdr; struct result_header hdr;
struct result_header_ext hdr_ext; struct result_header_ext hdr_ext;
@ -124,7 +124,7 @@ void wait_for_result()
} }
} }
void write_headers(struct file_header *hdr, char *filename) void write_headers(const struct file_header *hdr, const char *filename)
{ {
if (!write_all_with_crc(1, hdr, sizeof(*hdr)) if (!write_all_with_crc(1, hdr, sizeof(*hdr))
|| !write_all_with_crc(1, filename, hdr->namelen)) { || !write_all_with_crc(1, filename, hdr->namelen)) {
@ -134,7 +134,7 @@ void write_headers(struct file_header *hdr, char *filename)
} }
} }
int single_file_processor(char *filename, struct stat *st) int single_file_processor(const char *filename, const struct stat *st)
{ {
struct file_header hdr; struct file_header hdr;
int fd; int fd;

View File

@ -27,14 +27,14 @@ extern int ignore_symlinks;
void notify_progress(int size, int flag); void notify_progress(int size, int flag);
void do_notify_progress(long long total, int flag); void do_notify_progress(long long total, int flag);
void notify_end_and_wait_for_result(); void notify_end_and_wait_for_result(void);
void write_headers(struct file_header *hdr, char *filename); void write_headers(const struct file_header *hdr, const char *filename);
int write_all_with_crc(int fd, void *buf, int size); int write_all_with_crc(int fd, const void *buf, int size);
int single_file_processor(char *filename, struct stat *st); int single_file_processor(const char *filename, const struct stat *st);
void wait_for_result(); void wait_for_result(void);
#endif /* _LIBQUBES_QFILE_UTILS_H */ #endif /* _LIBQUBES_QFILE_UTILS_H */

View File

@ -12,9 +12,9 @@
#include <gui-fatal.h> #include <gui-fatal.h>
#include "dvm2.h" #include "dvm2.h"
void send_file(char *fname) void send_file(const char *fname)
{ {
char *base; const char *base;
char sendbuf[DVM_FILENAME_SIZE]; char sendbuf[DVM_FILENAME_SIZE];
int fd = open(fname, O_RDONLY); int fd = open(fname, O_RDONLY);
if (fd < 0) if (fd < 0)
@ -47,7 +47,7 @@ int copy_and_return_nonemptiness(int tmpfd)
return st.st_size > 0; return st.st_size > 0;
} }
void recv_file_nowrite(char *fname) void recv_file_nowrite(const char *fname)
{ {
char *tempfile; char *tempfile;
char *errmsg; char *errmsg;
@ -68,7 +68,7 @@ void recv_file_nowrite(char *fname)
gui_nonfatal(errmsg); gui_nonfatal(errmsg);
} }
void actually_recv_file(char *fname, char *tempfile, int tmpfd) void actually_recv_file(const char *fname, const char *tempfile, int tmpfd)
{ {
if (!copy_and_return_nonemptiness(tmpfd)) { if (!copy_and_return_nonemptiness(tmpfd)) {
unlink(tempfile); unlink(tempfile);
@ -78,7 +78,7 @@ void actually_recv_file(char *fname, char *tempfile, int tmpfd)
gui_fatal("rename"); gui_fatal("rename");
} }
void recv_file(char *fname) void recv_file(const char *fname)
{ {
int tmpfd; int tmpfd;
char *tempfile; char *tempfile;
@ -90,7 +90,7 @@ void recv_file(char *fname)
actually_recv_file(fname, tempfile, tmpfd); actually_recv_file(fname, tempfile, tmpfd);
} }
void talk_to_daemon(char *fname) void talk_to_daemon(const char *fname)
{ {
send_file(fname); send_file(fname);
recv_file(fname); recv_file(fname);

View File

@ -11,7 +11,7 @@
#define USER_HOME "/home/user" #define USER_HOME "/home/user"
#define MIMEINFO_DATABASES "/usr/share/mime:/usr/local/share:" USER_HOME "/.local/share:/usr/share/qubes/mime-override" #define MIMEINFO_DATABASES "/usr/share/mime:/usr/local/share:" USER_HOME "/.local/share:/usr/share/qubes/mime-override"
char *gettime() const char *gettime(void)
{ {
static char retbuf[60]; static char retbuf[60];
struct timeval tv; struct timeval tv;
@ -21,7 +21,7 @@ char *gettime()
return retbuf; return retbuf;
} }
char *get_filename() const char *get_filename(void)
{ {
char buf[DVM_FILENAME_SIZE]; char buf[DVM_FILENAME_SIZE];
static char retname[sizeof(buf) + sizeof("/tmp/")]; static char retname[sizeof(buf) + sizeof("/tmp/")];
@ -42,7 +42,7 @@ char *get_filename()
return retname; return retname;
} }
void copy_file(char *filename) void copy_file(const char *filename)
{ {
int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0600); int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0600);
if (fd < 0) { if (fd < 0) {
@ -54,7 +54,7 @@ void copy_file(char *filename)
close(fd); close(fd);
} }
void send_file_back(char * filename) void send_file_back(const char * filename)
{ {
int fd = open(filename, O_RDONLY); int fd = open(filename, O_RDONLY);
if (fd < 0) { if (fd < 0) {
@ -71,7 +71,7 @@ int
main() main()
{ {
struct stat stat_pre, stat_post, session_stat; struct stat stat_pre, stat_post, session_stat;
char *filename = get_filename(); const char *filename = get_filename();
int child, status, log_fd, null_fd; int child, status, log_fd, null_fd;
char var[1024], val[4096]; char var[1024], val[4096];
FILE *env_file; FILE *env_file;