Re: compile warnings: differ in signedness & declared with attribute warn_unused_result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 03 Mar 2008 21:11:11 +0100
Till Maas wrote:

> when I compile cryptsetup 1.0.6-pre2 for Fedora, there are several compile
> warnings. ....

There are some patches for eliminating such warnings, with them
cryptsetup successfully compiled with -Werror flag for ALT Linux
Sisyphus.

-- 
Best regards,
Nikolay Fetisov
Miscellaneous fixes for const modifiers in types

--- lib/libcryptsetup.h.orig    2007-12-22 12:23:13 +0300
+++ lib/libcryptsetup.h 2007-12-22 12:23:22 +0300
@@ -63,6 +63,6 @@
 
 void crypt_get_error(char *buf, size_t size);
 void crypt_put_options(struct crypt_options *options);
-const char *crypt_get_dir(void);
+char *crypt_get_dir(void);
 
 #endif /* _LIBCRYPTSETUP_H */
--- lib/setup.c.orig	2007-12-22 12:00:02 +0300
+++ lib/setup.c	2007-12-22 12:23:05 +0300
@@ -111,7 +111,7 @@
 	
 	/* key is coming from tty, fd or binary stdin */
 	if (options->hash) {
-		if (hash(NULL, options->hash,
+		if (hash(NULL, (const char*) options->hash,
 			 key, options->key_size,
 			 pass, passLen) < 0)
 		{
@@ -257,7 +257,7 @@
 		return -EINVAL;
 	}
 
-	if (get_device_infos(options->device, &infos) < 0)
+	if (get_device_infos((const char*) options->device, &infos) < 0)
 		return -ENOTBLK;
 
 	if (!options->size) {
@@ -276,7 +276,7 @@
 	if (infos.readonly)
 		options->flags |= CRYPT_FLAG_READONLY;
 
-	get_key("Enter passphrase: ", &key, &keyLen, options->key_size, options->key_file, options->passphrase_fd, options->timeout, options->flags);
+	get_key("Enter passphrase: ", &key, &keyLen, options->key_size, (const char*) options->key_file, options->passphrase_fd, options->timeout, options->flags);
 	if (!key) {
 		set_error("Key reading error");
 		return -ENOENT;
@@ -331,7 +331,7 @@
 	if (r < 0)
 		return r;
 
-	if (get_device_infos(tmp.device, &infos) < 0)
+	if (get_device_infos((const char*) tmp.device, &infos) < 0)
 		return -EINVAL;
 
 	if (!options->size) {
@@ -386,7 +386,7 @@
 	int passwordLen;
 	int PBKDF2perSecond;
 	
-	if (!LUKS_device_ready(options->device, O_RDWR | O_EXCL)) {
+	if (!LUKS_device_ready((const char*) options->device, O_RDWR | O_EXCL)) {
 		set_error("Can not access device");
 		r = -ENOTBLK; goto out;
 	}
@@ -412,7 +412,7 @@
 	printoffset(uuid);
 #endif
 
-	r = parse_into_name_and_mode(options->cipher, cipherName, cipherMode);
+	r = parse_into_name_and_mode((const char*) options->cipher, cipherName, cipherMode);
 	if(r < 0) return r;
 
 	r = LUKS_generate_phdr(&header,mk,cipherName, cipherMode,LUKS_STRIPES, options->align_payload);
@@ -426,13 +426,13 @@
 #ifdef LUKS_DEBUG
 	logger(options->icb->log,CRYPT_LOG_ERROR, "pitr %d\n", header.keyblock[0].passwordIterations);
 #endif
-	get_key("Enter LUKS passphrase: ",&password,&passwordLen, 0, options->new_key_file, options->passphrase_fd, options->timeout, options->flags);
+	get_key("Enter LUKS passphrase: ",&password,&passwordLen, 0, (const char*) options->new_key_file, options->passphrase_fd, options->timeout, options->flags);
 	if(!password) {
 		r = -EINVAL; goto out;
 	}
 
 	/* Set key, also writes phdr */
-	r = LUKS_set_key(options->device, options->key_slot==-1?0:(unsigned int)options->key_slot, password, passwordLen, &header, mk, backend);
+	r = LUKS_set_key((const char*) options->device, options->key_slot==-1?0:(unsigned int)options->key_slot, password, passwordLen, &header, mk, backend);
 	if(r < 0) goto out; 
 
 	r = 0;
@@ -461,12 +461,12 @@
 		return -EEXIST;
 	}
 
-	if (!LUKS_device_ready(options->device, O_RDONLY | O_EXCL)) {
+	if (!LUKS_device_ready((const char*) options->device, O_RDONLY | O_EXCL)) {
 		set_error("Can not access device");
 		return -ENOTBLK;
 	}
 
-	if (get_device_infos(options->device, &infos) < 0) {
+	if (get_device_infos((const char*)options->device, &infos) < 0) {
 		set_error("Can't get device information.\n");
 		return -ENOTBLK;
 	}
@@ -477,7 +477,7 @@
 start:
 	mk=NULL;
 
-	if(get_key("Enter LUKS passphrase: ",&password,&passwordLen, 0, options->key_file,  options->passphrase_fd, options->timeout, options->flags))
+	if(get_key("Enter LUKS passphrase: ",&password,&passwordLen, 0, (const char*) options->key_file,  options->passphrase_fd, options->timeout, options->flags))
 		tries--;
 	else
 		tries = 0;
@@ -486,7 +486,7 @@
 		r = -EINVAL; goto out;
 	}
         
-        r = LUKS_open_any_key(options->device, password, passwordLen, &hdr, &mk, backend);
+        r = LUKS_open_any_key((const char*) options->device, password, passwordLen, &hdr, &mk, backend);
 	if(r < 0) {
 		set_error("No key available with this passphrase.\n");
 		goto out1;
@@ -534,7 +534,7 @@
 	struct luks_phdr hdr;
 	char *password=NULL; int passwordLen;
 	unsigned int i; unsigned int keyIndex;
-	const char *device = options->device;
+	const char *device = (const char*) options->device;
 	struct crypt_options optionsCheck = { 
 		.key_file = options->key_file,
 		.flags = options->flags & ~(CRYPT_FLAG_VERIFY | CRYPT_FLAG_VERIFY_IF_POSSIBLE),
@@ -546,7 +546,7 @@
 	int r;
 	int key_slot = options->key_slot;
 	
-	if (!LUKS_device_ready(options->device, O_RDWR)) {
+	if (!LUKS_device_ready((const char*) options->device, O_RDWR)) {
 		set_error("Can not access device");
 		r = -ENOTBLK; goto out;
 	}
@@ -577,7 +577,7 @@
         }
 
 	optionsCheck.key_size = 0; // FIXME, define a clean interface some day.
-	get_key("Enter any LUKS passphrase: ",&password,&passwordLen, options->key_size, options->key_file, options->passphrase_fd, options->timeout, options->flags & ~(CRYPT_FLAG_VERIFY | CRYPT_FLAG_VERIFY_IF_POSSIBLE));
+	get_key("Enter any LUKS passphrase: ",&password,&passwordLen, options->key_size, (const char*) options->key_file, options->passphrase_fd, options->timeout, options->flags & ~(CRYPT_FLAG_VERIFY | CRYPT_FLAG_VERIFY_IF_POSSIBLE));
 	if(!password) {
 		r = -EINVAL; goto out;
 	}
@@ -591,7 +591,7 @@
 	safe_free(password);
 	
 	optionsSet.key_size = 0; // FIXME, define a clean interface some day.
-	get_key("Enter new passphrase for key slot: ",&password,&passwordLen, options->key_size, options->new_key_file, options->passphrase_fd, options->timeout, options->flags);
+	get_key("Enter new passphrase for key slot: ",&password,&passwordLen, options->key_size, (const char*) options->new_key_file, options->passphrase_fd, options->timeout, options->flags);
 	if(!password) {
 		r = -EINVAL; goto out;
 	}
@@ -614,17 +614,17 @@
 	struct luks_phdr hdr;
 	char *password=NULL; 
 	int passwordLen;
-	const char *device = options->device;
+	const char *device = (const char*) options->device;
 	int keyIndex;
 	int openedIndex;
 	int r;
-	if (!LUKS_device_ready(options->device, O_RDWR)) {
+	if (!LUKS_device_ready((const char*) options->device, O_RDWR)) {
 	    set_error("Can not access device");
 	    r = -ENOTBLK; goto out;
 	}
 
 	if(supply_it) {
-	    get_key("Enter LUKS passphrase to be deleted: ",&password,&passwordLen, 0, options->new_key_file, options->passphrase_fd, options->timeout, options->flags);
+	    get_key("Enter LUKS passphrase to be deleted: ",&password,&passwordLen, 0, (const char*) options->new_key_file, options->passphrase_fd, options->timeout, options->flags);
 	    if(!password) {
 		    r = -EINVAL; goto out;
 	    }
@@ -639,7 +639,7 @@
 	    keyIndex = options->key_slot;
 	}
 
-	if(LUKS_is_last_keyslot(options->device, keyIndex) && 
+	if(LUKS_is_last_keyslot((const char*) options->device, keyIndex) && 
 	   !(options->icb->yesDialog(_("This is the last keyslot. Device will become unusable after purging this key.")))) {
 		r = -EINVAL;
 		goto out;
@@ -647,7 +647,7 @@
 
 	if(options->flags & CRYPT_FLAG_VERIFY_ON_DELKEY) {
 		options->flags &= ~CRYPT_FLAG_VERIFY_ON_DELKEY;
-		get_key("Enter any remaining LUKS passphrase: ",&password,&passwordLen, 0, options->key_file, options->passphrase_fd, options->timeout, options->flags);
+		get_key("Enter any remaining LUKS passphrase: ",&password,&passwordLen, 0, (const char*) options->key_file, options->passphrase_fd, options->timeout, options->flags);
 		if(!password) {
 			r = -EINVAL; goto out;
 		}
@@ -766,7 +766,7 @@
 	struct luks_phdr hdr;
 	int r;
 
-	r = LUKS_read_phdr(options->device,&hdr);
+	r = LUKS_read_phdr((const char*)options->device,&hdr);
 	if(r < 0) return r;
 
 	options->icb->log(CRYPT_LOG_NORMAL,hdr.uuid);
@@ -777,7 +777,7 @@
 int crypt_isLuks(struct crypt_options *options)
 {
 	struct luks_phdr hdr;
-	return LUKS_read_phdr(options->device,&hdr);
+	return LUKS_read_phdr((const char*) options->device,&hdr);
 }
 
 int crypt_luksDump(struct crypt_options *options)
@@ -785,7 +785,7 @@
 	struct luks_phdr hdr;
 	int r,i;
 
-	r = LUKS_read_phdr(options->device,&hdr);
+	r = LUKS_read_phdr((const char*) options->device,&hdr);
 	if(r < 0) return r;
 
 	logger(options, CRYPT_LOG_NORMAL, "LUKS header information for %s\n\n",options->device);
@@ -863,7 +863,7 @@
 		default_backend = NULL;
 }
 
-const char *crypt_get_dir(void)
+char *crypt_get_dir(void)
 {
 	struct setup_backend *backend;
 	const char *dir;
@@ -876,7 +876,7 @@
 
 	put_setup_backend(backend);
 
-	return dir;
+	return (char*) dir;
 }
 
 // Local Variables:
Fix type casts to meet libdevmapper.h declarations

--- lib/libdevmapper.c.orig	2007-12-22 13:28:36 +0300
+++ lib/libdevmapper.c	2007-12-22 13:29:11 +0300
@@ -33,7 +33,7 @@
 
 static int dm_init(void)
 {
-	dm_log_init(set_dm_error);
+	dm_log_init((dm_log_fn) set_dm_error);
 	return 1;	/* unsafe memory */
 }
 
@@ -382,7 +382,7 @@
 
 static const char *dm_get_dir(void)
 {
-	return dm_dir();
+	return (const char*) dm_dir();
 }
 
 struct setup_backend setup_libdevmapper_backend = {
passwordLen in get_key have signed int type.

--- lib/setup.c.orig	2007-12-18 20:22:33 +0300
+++ lib/setup.c	2007-12-18 20:23:01 +0300
@@ -532,7 +532,7 @@
 {
 	struct luks_masterkey *mk=NULL;
 	struct luks_phdr hdr;
-	char *password=NULL; unsigned int passwordLen;
+	char *password=NULL; int passwordLen;
 	unsigned int i; unsigned int keyIndex;
 	const char *device = options->device;
 	struct crypt_options optionsCheck = { 
@@ -613,7 +613,7 @@
 	struct luks_masterkey *mk;
 	struct luks_phdr hdr;
 	char *password=NULL; 
-	unsigned int passwordLen;
+	int passwordLen;
 	const char *device = options->device;
 	int keyIndex;
 	int openedIndex;
Fixes for variable's signedness

--- ./luks/af.c	2007-03-04 12:39:52 +0300
+++ ./luks/af.c	2007-03-04 12:56:48 +0300
@@ -87,7 +87,7 @@
 		if(r < 0) goto out;
 
 		XORblock(dst+(blocksize*i),bufblock,bufblock,blocksize);
-		diffuse(bufblock,bufblock,blocksize);
+		diffuse((unsigned char *)bufblock,(unsigned char *)bufblock,blocksize);
 	}
 	/* the last block is computed */
 	XORblock(src,bufblock,dst+(i*blocksize),blocksize);
@@ -107,7 +107,7 @@
 	memset(bufblock,0,blocksize);
 	for(i=0; i<blocknumbers-1; i++) {
 		XORblock(src+(blocksize*i),bufblock,bufblock,blocksize);
-		diffuse(bufblock,bufblock,blocksize);
+		diffuse((unsigned char *)bufblock,(unsigned char *)bufblock,blocksize);
 	}
 	XORblock(src + blocksize * i, bufblock, dst, blocksize);
 
Fix for ignoring return values when compiling with -Werror 

--- lib/setup.c.orig	2007-12-18 15:08:55 +0300
+++ lib/setup.c	2007-12-18 15:18:51 +0300
@@ -29,9 +29,10 @@
 static void logger(struct crypt_options *options, int class, char *format, ...) {
         va_list argp;
         char *target;
+	int outlen;
 
         va_start(argp, format);
-        vasprintf(&target, format, argp);
+        outlen=vasprintf(&target, format, argp);
         options->icb->log(class, target);
 
         va_end(argp);
@@ -288,7 +289,8 @@
 		const char *error=get_error();
 		if(error) {
 			char *c_error_handling_sucks;
-			asprintf(&c_error_handling_sucks,"Key processing error: %s",error);
+			int outlen;
+			outlen=asprintf(&c_error_handling_sucks,"Key processing error: %s",error);
 			set_error(c_error_handling_sucks);
 			free(c_error_handling_sucks);
 		} else
@@ -451,6 +453,7 @@
 	};
 	char *dmCipherSpec;
 	int r, tries = options->tries;
+	int outlen;
 	
 	r = backend->status(0, &tmp, NULL);
 	if (r >= 0) {
@@ -492,7 +495,7 @@
 
 	
 	options->offset = hdr.payloadOffset;
- 	asprintf(&dmCipherSpec, "%s-%s", hdr.cipherName, hdr.cipherMode);
+ 	outlen=asprintf(&dmCipherSpec, "%s-%s", hdr.cipherName, hdr.cipherMode);
 	if(!dmCipherSpec) {
 		r = -ENOMEM;
 		goto out2;
--- lib/utils.c.orig	2007-12-18 20:27:19 +0300
+++ lib/utils.c	2007-12-18 20:28:23 +0300
@@ -26,13 +26,13 @@
 
 void set_error_va(const char *fmt, va_list va)
 {
-
+	int outlen;
 	if(error) {
 	    free(error);
 	    error=NULL;
 	}
 
-        vasprintf(&error, fmt, va);
+        outlen=vasprintf(&error, fmt, va);
 }
 
 void set_error(const char *fmt, ...)
@@ -295,6 +295,7 @@
 	struct termios orig, tmp;
 	int failed = -1;
 	int infd = STDIN_FILENO, outfd;
+	int outlen;
 
 	if (maxlen < 1)
 		goto out_err;
@@ -312,7 +313,7 @@
 	memcpy(&tmp, &orig, sizeof(tmp));
 	tmp.c_lflag &= ~ECHO;
 
-	write(outfd, prompt, strlen(prompt));
+	outlen=write(outfd, prompt, strlen(prompt));
 	tcsetattr(infd, TCSAFLUSH, &tmp);
 	if (timeout)
 		failed = timed_read(infd, pass, maxlen, timeout);
@@ -322,7 +323,7 @@
 
 out_err:
 	if (!failed)
-		write(outfd, "\n", 1);
+		outlen=write(outfd, "\n", 1);
 	if (infd != STDIN_FILENO)
 		close(infd);
 	return failed;

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Mapper Devel]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux