Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jun 2012 10:50:46 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r236507 - head/sbin/hastd
Message-ID:  <201206031050.q53AokSA056352@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sun Jun  3 10:50:46 2012
New Revision: 236507
URL: http://svn.freebsd.org/changeset/base/236507

Log:
  Simplify the code by using snprlcat().
  
  MFC after:	3 days

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==============================================================================
--- head/sbin/hastd/primary.c	Sun Jun  3 09:37:47 2012	(r236506)
+++ head/sbin/hastd/primary.c	Sun Jun  3 10:50:46 2012	(r236507)
@@ -990,36 +990,33 @@ reqlog(int loglevel, int debuglevel, str
 {
 	char msg[1024];
 	va_list ap;
-	int len;
 
 	va_start(ap, fmt);
-	len = vsnprintf(msg, sizeof(msg), fmt, ap);
+	(void)vsnprintf(msg, sizeof(msg), fmt, ap);
 	va_end(ap);
-	if ((size_t)len < sizeof(msg)) {
-		switch (ggio->gctl_cmd) {
-		case BIO_READ:
-			(void)snprintf(msg + len, sizeof(msg) - len,
-			    "READ(%ju, %ju).", (uintmax_t)ggio->gctl_offset,
-			    (uintmax_t)ggio->gctl_length);
-			break;
-		case BIO_DELETE:
-			(void)snprintf(msg + len, sizeof(msg) - len,
-			    "DELETE(%ju, %ju).", (uintmax_t)ggio->gctl_offset,
-			    (uintmax_t)ggio->gctl_length);
-			break;
-		case BIO_FLUSH:
-			(void)snprintf(msg + len, sizeof(msg) - len, "FLUSH.");
-			break;
-		case BIO_WRITE:
-			(void)snprintf(msg + len, sizeof(msg) - len,
-			    "WRITE(%ju, %ju).", (uintmax_t)ggio->gctl_offset,
-			    (uintmax_t)ggio->gctl_length);
-			break;
-		default:
-			(void)snprintf(msg + len, sizeof(msg) - len,
-			    "UNKNOWN(%u).", (unsigned int)ggio->gctl_cmd);
-			break;
-		}
+	switch (ggio->gctl_cmd) {
+	case BIO_READ:
+		(void)snprlcat(msg, sizeof(msg), "READ(%ju, %ju).",
+		    (uintmax_t)ggio->gctl_offset,
+		    (uintmax_t)ggio->gctl_length);
+		break;
+	case BIO_DELETE:
+		(void)snprlcat(msg, sizeof(msg), "DELETE(%ju, %ju).",
+		    (uintmax_t)ggio->gctl_offset,
+		    (uintmax_t)ggio->gctl_length);
+		break;
+	case BIO_FLUSH:
+		(void)snprlcat(msg, sizeof(msg), "FLUSH.");
+		break;
+	case BIO_WRITE:
+		(void)snprlcat(msg, sizeof(msg), "WRITE(%ju, %ju).",
+		    (uintmax_t)ggio->gctl_offset,
+		    (uintmax_t)ggio->gctl_length);
+		break;
+	default:
+		(void)snprlcat(msg, sizeof(msg), "UNKNOWN(%u).",
+		    (unsigned int)ggio->gctl_cmd);
+		break;
 	}
 	pjdlog_common(loglevel, debuglevel, -1, "%s", msg);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206031050.q53AokSA056352>