Przeglądaj źródła

core-agent-linux: misc const/void fixups

Vincent Penquerc'h 10 lat temu
rodzic
commit
9a4b1efa61

+ 2 - 2
qubes-rpc/gui-fatal.c

@@ -8,12 +8,12 @@
 #include <unistd.h>
 #include <stdarg.h>
 
-static void fix_display()
+static void fix_display(void)
 {
 	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 buf[1024];

+ 1 - 1
qubes-rpc/ioall.h

@@ -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 copy_fd_all(int fdout, int fdin);
 void set_nonblock(int fd);

+ 2 - 2
qubes-rpc/qfile-agent.c

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

+ 1 - 1
qubes-rpc/qfile-unpacker.c

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

+ 8 - 8
qubes-rpc/qfile-utils.c

@@ -24,9 +24,9 @@ void notify_progress(int size, int flag)
 
 void do_notify_progress(long long total, int flag)
 {
-	char *du_size_env = getenv("FILECOPY_TOTAL_SIZE");
-	char *progress_type_env = getenv("PROGRESS_TYPE");
-	char *saved_stdout_env = getenv("SAVED_FD_1");
+	const char *du_size_env = getenv("FILECOPY_TOTAL_SIZE");
+	const char *progress_type_env = getenv("PROGRESS_TYPE");
+	const char *saved_stdout_env = getenv("SAVED_FD_1");
 	if (!progress_type_env)
 		return;
 	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;
 
@@ -59,13 +59,13 @@ void notify_end_and_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);
 	return write_all(fd, buf, size);
 }
 
-void wait_for_result()
+void wait_for_result(void)
 {
 	struct result_header hdr;
 	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))
 	    || !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;
 	int fd;

+ 5 - 5
qubes-rpc/qfile-utils.h

@@ -27,14 +27,14 @@ extern int ignore_symlinks;
 
 void notify_progress(int size, 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 */

+ 6 - 6
qubes-rpc/qopen-in-vm.c

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

+ 5 - 5
qubes-rpc/vm-file-editor.c

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