svn commit: r306329 - head/usr.bin/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Mon Sep 26 00:41:09 UTC 2016


Author: marcel
Date: Mon Sep 26 00:41:08 2016
New Revision: 306329
URL: https://svnweb.freebsd.org/changeset/base/306329

Log:
  Eliminate the use of EDOOFUS.  The error code was used to signal
  programming errors, but is really a poor substitute for assert.
  And less portable as well.

Modified:
  head/usr.bin/mkimg/image.c
  head/usr.bin/mkimg/qcow.c

Modified: head/usr.bin/mkimg/image.c
==============================================================================
--- head/usr.bin/mkimg/image.c	Sun Sep 25 23:48:15 2016	(r306328)
+++ head/usr.bin/mkimg/image.c	Mon Sep 26 00:41:08 2016	(r306329)
@@ -456,8 +456,7 @@ image_copyin_mapped(lba_t blk, int fd, u
 			 * I don't know what this means or whether it
 			 * can happen at all...
 			 */
-			error = EDOOFUS;
-			break;
+			assert(0);
 		}
 	}
 	if (error)
@@ -602,7 +601,7 @@ image_copyout_region(int fd, lba_t blk, 
 			error = image_copyout_memory(fd, sz, ch->ch_u.mem.ptr);
 			break;
 		default:
-			return (EDOOFUS);
+			assert(0);
 		}
 		size -= sz;
 		blk += sz / secsz;

Modified: head/usr.bin/mkimg/qcow.c
==============================================================================
--- head/usr.bin/mkimg/qcow.c	Sun Sep 25 23:48:15 2016	(r306328)
+++ head/usr.bin/mkimg/qcow.c	Mon Sep 26 00:41:08 2016	(r306329)
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/types.h>
 #include <sys/endian.h>
 #include <sys/errno.h>
+#include <assert.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -102,7 +103,7 @@ qcow_resize(lba_t imgsz, u_int version)
 		clstr_log2sz = QCOW2_CLSTR_LOG2SZ;
 		break;
 	default:
-		return (EDOOFUS);
+		assert(0);
 	}
 
 	imagesz = round_clstr(imgsz * secsz);
@@ -143,8 +144,7 @@ qcow_write(int fd, u_int version)
 	u_int clstrsz, l1idx, l2idx;
 	int error;
 
-	if (clstr_log2sz == 0)
-		return (EDOOFUS);
+	assert(clstr_log2sz != 0);
 
 	clstrsz = 1U << clstr_log2sz;
 	blk_clstrsz = clstrsz / secsz;
@@ -203,7 +203,7 @@ qcow_write(int fd, u_int version)
 		be32enc(&hdr->u.v2.refcnt_clstrs, refcnt_clstrs);
 		break;
 	default:
-		return (EDOOFUS);
+		assert(0);
 	}
 
 	if (sparse_write(fd, hdr, clstrsz) < 0) {


More information about the svn-src-head mailing list