setup: delpasswd.c, joinpasswd.c, postshell.c, update-fstab.c ssize_t for s...

arekm arekm at pld-linux.org
Fri May 31 20:50:45 CEST 2013


Author: arekm                        Date: Fri May 31 18:50:45 2013 GMT
Module: setup                         Tag: HEAD
---- Log message:
ssize_t for size variables. Use own error function instead of problematic error macro.

---- Files affected:
setup:
   delpasswd.c (1.5 -> 1.6) , joinpasswd.c (1.15 -> 1.16) , postshell.c (1.7 -> 1.8) , update-fstab.c (1.6 -> 1.7) 

---- Diffs:

================================================================
Index: setup/delpasswd.c
diff -u setup/delpasswd.c:1.5 setup/delpasswd.c:1.6
--- setup/delpasswd.c:1.5	Fri May 31 20:37:04 2013
+++ setup/delpasswd.c	Fri May 31 20:50:39 2013
@@ -92,7 +92,7 @@
 	exit(1);
 }
 
-char *map_file(const char *name, size_t *sz)
+char *map_file(const char *name, ssize_t *sz)
 {
 	int fd;
 	void *ptr;
@@ -252,7 +252,7 @@
 int verifyp(const char *old_name, int namesc, const char **names)
 {
 	char *old, *id;
-	size_t i, old_sz;
+	ssize_t i, old_sz;
 
 	// Fail silently if file does not exist
 	if (access(old_name, F_OK) == -1)
@@ -288,7 +288,7 @@
 {
 	char *old, *tmp, *id;
 	int fd;
-	size_t i, old_sz;
+	ssize_t i, old_sz;
 
 	// Fail silently if file does not exist
 	if (access(old_name, F_OK) == -1)
@@ -302,7 +302,8 @@
 	fd = open(backup_name, O_WRONLY|O_CREAT|O_TRUNC, 0600);
 	if (fd < 0)
 		fatal("cannot make backup");
-	write(fd, tmp, old_sz);
+	if (write(fd, tmp, old_sz) < 0)
+		fatal("writting to backup failed");
 	close(fd);
 	
 	old = map_file(backup_name, &old_sz);

================================================================
Index: setup/joinpasswd.c
diff -u setup/joinpasswd.c:1.15 setup/joinpasswd.c:1.16
--- setup/joinpasswd.c:1.15	Fri May 31 20:37:04 2013
+++ setup/joinpasswd.c	Fri May 31 20:50:39 2013
@@ -105,7 +105,7 @@
 	exit(1);
 }
 
-char *map_file(const char *name, size_t *sz)
+char *map_file(const char *name, ssize_t *sz)
 {
 	int fd;
 	void *ptr;
@@ -124,9 +124,9 @@
 	return ptr;
 }
 
-int exist(char *id, int id_len, char *ptr, size_t sz)
+int exist(char *id, int id_len, char *ptr, ssize_t sz)
 {
-	size_t i;
+	ssize_t i;
 
 	for (i = 0; i < sz; ) {
 		if (sz - i > id_len && memcmp(id, ptr + i, id_len + 1) == 0)
@@ -273,7 +273,7 @@
 {
 	char *old, *new, *id;
 	int i, fd;
-	size_t old_sz, new_sz;
+	ssize_t old_sz, new_sz;
 
 	new = map_file(new_name, &new_sz);
 	if (new == NULL)

================================================================
Index: setup/postshell.c
diff -u setup/postshell.c:1.7 setup/postshell.c:1.8
--- setup/postshell.c:1.7	Fri Oct 14 12:14:36 2011
+++ setup/postshell.c	Fri May 31 20:50:40 2013
@@ -231,7 +231,10 @@
 	}
 }
 
-#define error(msg) write(2, msg, strlen(msg))
+ssize_t error(char *msg) {
+	return write(2, msg, strlen(msg));
+}
+
 int main(int argc, char **argv)
 {
 	int fd;

================================================================
Index: setup/update-fstab.c
diff -u setup/update-fstab.c:1.6 setup/update-fstab.c:1.7
--- setup/update-fstab.c:1.6	Fri May 31 20:37:04 2013
+++ setup/update-fstab.c	Fri May 31 20:50:40 2013
@@ -25,7 +25,7 @@
 	
 	char *old;
 	int fd;
-	size_t i, old_sz;
+	ssize_t i, old_sz;
 	struct stat st;
 
 	eputs("Updating /etc/fstab...");
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/setup/delpasswd.c?r1=1.5&r2=1.6
    http://cvs.pld-linux.org/setup/joinpasswd.c?r1=1.15&r2=1.16
    http://cvs.pld-linux.org/setup/postshell.c?r1=1.7&r2=1.8
    http://cvs.pld-linux.org/setup/update-fstab.c?r1=1.6&r2=1.7



More information about the pld-cvs-commit mailing list