[asterisk-commits] mjordan: trunk r433692 - in /trunk: ./ formats/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 28 07:48:47 CDT 2015


Author: mjordan
Date: Sat Mar 28 07:48:45 2015
New Revision: 433692

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433692
Log:
clang compiler warnings: Fix -Wself-assign

Assigning a variable to itself isn't super useful. However, the WAV format
modules make use of this in order to perform byte endian checks. This patch
works around the warning by only performing the self assignment if we are
going to do more than just assign it to ourselves. Which is odd, but true.

Review: https://reviewboard.asterisk.org/r/4544/

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4544.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433690 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433691 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/formats/format_wav.c
    trunk/formats/format_wav_gsm.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/formats/format_wav.c
URL: http://svnview.digium.com/svn/asterisk/trunk/formats/format_wav.c?view=diff&rev=433692&r1=433691&r2=433692
==============================================================================
--- trunk/formats/format_wav.c (original)
+++ trunk/formats/format_wav.c Sat Mar 28 07:48:45 2015
@@ -64,14 +64,14 @@
 #define ltohs(b) (b)
 #else
 #if __BYTE_ORDER == __BIG_ENDIAN
-#define htoll(b)  \
-          (((((b)      ) & 0xFF) << 24) | \
-	       ((((b) >>  8) & 0xFF) << 16) | \
-		   ((((b) >> 16) & 0xFF) <<  8) | \
-		   ((((b) >> 24) & 0xFF)      ))
+#define htoll(b) \
+	(((((b)      ) & 0xFF) << 24) | \
+	((( (b) >>  8) & 0xFF) << 16) | \
+	((( (b) >> 16) & 0xFF) <<  8) | \
+	((( (b) >> 24) & 0xFF)      ))
 #define htols(b) \
-          (((((b)      ) & 0xFF) << 8) | \
-		   ((((b) >> 8) & 0xFF)      ))
+	(((((b)      ) & 0xFF) <<  8) | \
+	((( (b) >>  8) & 0xFF)      ))
 #define ltohl(b) htoll(b)
 #define ltohs(b) htols(b)
 #else
@@ -110,8 +110,8 @@
 		return -1;
 	}
 	if (((ltohl(freq) != 8000) && (ltohl(freq) != 16000)) ||
-	    ((ltohl(freq) == 8000) && (hz != 8000)) ||
-	    ((ltohl(freq) == 16000) && (hz != 16000))) {
+		((ltohl(freq) == 8000) && (hz != 8000)) ||
+		((ltohl(freq) == 16000) && (hz != 16000))) {
 		ast_log(LOG_WARNING, "Unexpected frequency mismatch %d (expecting %d)\n", ltohl(freq),hz);
 		return -1;
 	}
@@ -153,7 +153,9 @@
 		ast_log(LOG_WARNING, "Read failed (size)\n");
 		return -1;
 	}
+#if __BYTE_ORDER == __BIG_ENDIAN
 	size = ltohl(size);
+#endif
 	if (fread(&formtype, 1, 4, f) != 4) {
 		ast_log(LOG_WARNING, "Read failed (formtype)\n");
 		return -1;
@@ -170,30 +172,32 @@
 	for(;;)
 	{ 
 		char buf[4];
-	    
-	    /* Begin data chunk */
-	    if (fread(&buf, 1, 4, f) != 4) {
+		
+		/* Begin data chunk */
+		if (fread(&buf, 1, 4, f) != 4) {
 			ast_log(LOG_WARNING, "Read failed (block header format)\n");
 			return -1;
-	    }
-	    /* Data has the actual length of data in it */
-	    if (fread(&data, 1, 4, f) != 4) {
+		}
+		/* Data has the actual length of data in it */
+		if (fread(&data, 1, 4, f) != 4) {
 			ast_log(LOG_WARNING, "Read failed (block '%.4s' header length)\n", buf);
 			return -1;
-	    }
-	    data = ltohl(data);
+		}
+#if __BYTE_ORDER == __BIG_ENDIAN
+		data = ltohl(data);
+#endif
 		if (memcmp(&buf, "fmt ", 4) == 0) {
 			if (check_header_fmt(f, data, hz))
 				return -1;
 			continue;
 		}
-	    if(memcmp(buf, "data", 4) == 0 ) 
+		if(memcmp(buf, "data", 4) == 0 ) 
 			break;
 		ast_log(LOG_DEBUG, "Skipping unknown block '%.4s'\n", buf);
-	    if (fseek(f,data,SEEK_CUR) == -1 ) {
+		if (fseek(f,data,SEEK_CUR) == -1 ) {
 			ast_log(LOG_WARNING, "Failed to skip '%.4s' block: %d\n", buf, data);
 			return -1;
-	    }
+		}
 	}
 #if 0
 	curpos = lseek(fd, 0, SEEK_CUR);
@@ -461,13 +465,14 @@
 		return -1;
 	}
 
-	if (whence == SEEK_SET)
+	if (whence == SEEK_SET) {
 		offset = samples + min;
-	else if (whence == SEEK_CUR || whence == SEEK_FORCECUR)
+	} else if (whence == SEEK_CUR || whence == SEEK_FORCECUR) {
 		offset = samples + cur;
-	else if (whence == SEEK_END)
+	} else if (whence == SEEK_END) {
 		offset = max - samples;
-        if (whence != SEEK_FORCECUR) {
+	}
+	if (whence != SEEK_FORCECUR) {
 		offset = (offset > max)?max:offset;
 	}
 	/* always protect the header space. */

Modified: trunk/formats/format_wav_gsm.c
URL: http://svnview.digium.com/svn/asterisk/trunk/formats/format_wav_gsm.c?view=diff&rev=433692&r1=433691&r2=433692
==============================================================================
--- trunk/formats/format_wav_gsm.c (original)
+++ trunk/formats/format_wav_gsm.c Sat Mar 28 07:48:45 2015
@@ -74,14 +74,14 @@
 #define ltohs(b) (b)
 #else
 #if __BYTE_ORDER == __BIG_ENDIAN
-#define htoll(b)  \
-          (((((b)      ) & 0xFF) << 24) | \
-	       ((((b) >>  8) & 0xFF) << 16) | \
-		   ((((b) >> 16) & 0xFF) <<  8) | \
-		   ((((b) >> 24) & 0xFF)      ))
+#define htoll(b) \
+	(((((b)      ) & 0xFF) << 24) | \
+	((( (b) >>  8) & 0xFF) << 16) | \
+	((( (b) >> 16) & 0xFF) <<  8) | \
+	((( (b) >> 24) & 0xFF)      ))
 #define htols(b) \
-          (((((b)      ) & 0xFF) << 8) | \
-		   ((((b) >> 8) & 0xFF)      ))
+	(((((b)      ) & 0xFF) <<  8) | \
+	((( (b) >>  8) & 0xFF)      ))
 #define ltohl(b) htoll(b)
 #define ltohs(b) htols(b)
 #else
@@ -105,7 +105,9 @@
 		ast_log(LOG_WARNING, "Read failed (size)\n");
 		return -1;
 	}
+#if __BYTE_ORDER == __BIG_ENDIAN
 	size = ltohl(size);
+#endif
 	if (fread(&formtype, 1, 4, f) != 4) {
 		ast_log(LOG_WARNING, "Read failed (formtype)\n");
 		return -1;




More information about the asterisk-commits mailing list