File tor-0.3.0.7-gcc7-fallthrough.patch of Package tor

fix -Wimplicit-fallthrough in GCC 7 on master, by adding magic comments
recognized bu -Wimplicit-fallthrough=3, or break, as required.

https://trac.torproject.org/projects/tor/ticket/22446

From a7400446b76977bb84b9b00fd92bd49a0694d028 Mon Sep 17 00:00:00 2001
From: Andreas Stieger <astieger@suse.com>
Date: Sun, 28 May 2017 22:08:56 +0200
Subject: [PATCH] Fix implicit fallthrough warning in GCC 7 in
 tor_gzip_compress, tor_gzip_uncompress

---
 src/common/torgzip.c | 2 ++
 1 file changed, 2 insertions(+)

Index: tor-0.3.0.7/src/common/torgzip.c
===================================================================
--- tor-0.3.0.7.orig/src/common/torgzip.c	2017-04-24 21:34:15.000000000 +0200
+++ tor-0.3.0.7/src/common/torgzip.c	2017-05-31 11:56:22.864546296 +0200
@@ -181,6 +181,7 @@ tor_gzip_compress(char **out, size_t *ou
         /* In case zlib doesn't work as I think .... */
         if (stream->avail_out >= stream->avail_in+16)
           break;
+        /* falls through */
       case Z_BUF_ERROR:
         offset = stream->next_out - ((unsigned char*)*out);
         old_size = out_size;
@@ -319,6 +320,7 @@ tor_gzip_uncompress(char **out, size_t *
         /* In case zlib doesn't work as I think.... */
         if (stream->avail_out >= stream->avail_in+16)
           break;
+        /* Falls through */
       case Z_BUF_ERROR:
         if (stream->avail_out > 0) {
           log_fn(protocol_warn_level, LD_PROTOCOL,
Index: tor-0.3.0.7/src/ext/csiphash.c
===================================================================
--- tor-0.3.0.7.orig/src/ext/csiphash.c	2017-04-24 21:34:15.000000000 +0200
+++ tor-0.3.0.7/src/ext/csiphash.c	2017-05-31 11:56:22.864546296 +0200
@@ -122,13 +122,13 @@ uint64_t siphash24(const void *src, unsi
 	}
 
 	switch (src_sz - blocks) {
-		case 7: last7 |= (uint64_t)m[i + 6] << 48;
-		case 6: last7 |= (uint64_t)m[i + 5] << 40;
-		case 5: last7 |= (uint64_t)m[i + 4] << 32;
-		case 4: last7 |= (uint64_t)m[i + 3] << 24;
-		case 3: last7 |= (uint64_t)m[i + 2] << 16;
-		case 2: last7 |= (uint64_t)m[i + 1] <<  8;
-		case 1: last7 |= (uint64_t)m[i + 0]      ;
+		case 7: last7 |= (uint64_t)m[i + 6] << 48; /* Falls through. */
+		case 6: last7 |= (uint64_t)m[i + 5] << 40; /* Falls through. */
+		case 5:	last7 |= (uint64_t)m[i + 4] << 32; /* Falls through. */
+		case 4: last7 |= (uint64_t)m[i + 3] << 24; /* Falls through. */
+		case 3:	last7 |= (uint64_t)m[i + 2] << 16; /* Falls through. */
+		case 2:	last7 |= (uint64_t)m[i + 1] <<  8; /* Falls through. */
+		case 1: last7 |= (uint64_t)m[i + 0]      ; /* Falls through. */
 		case 0:
 		default:;
 	}
Index: tor-0.3.0.7/src/ext/ed25519/donna/modm-donna-64bit.h
===================================================================
--- tor-0.3.0.7.orig/src/ext/ed25519/donna/modm-donna-64bit.h	2017-03-05 01:44:57.000000000 +0100
+++ tor-0.3.0.7/src/ext/ed25519/donna/modm-donna-64bit.h	2017-05-31 11:56:22.864546296 +0200
@@ -294,10 +294,10 @@ sub256_modm_batch(bignum256modm out, con
 	size_t i = 0;
 	bignum256modm_element_t carry = 0;
 	switch (limbsize) {
-		case 4: out[i] = (a[i] - b[i])        ; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
-		case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
-		case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
-		case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++;
+		case 4: out[i] = (a[i] - b[i])        ; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
+		case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
+		case 2:	out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
+		case 1:	out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 63); out[i] &= 0xffffffffffffff; i++; /* Falls through. */
 		case 0: 
 		default: out[i] = (a[i] - b[i]) - carry;
 	}
@@ -310,10 +310,10 @@ lt256_modm_batch(const bignum256modm a,
 	size_t i = 0;
 	bignum256modm_element_t t, carry = 0;
 	switch (limbsize) {
-		case 4: t = (a[i] - b[i])        ; carry = (t >> 63); i++;
-		case 3: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++;
-		case 2: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++;
-		case 1: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++;
+		case 4: t = (a[i] - b[i])        ; carry = (t >> 63); i++; /* Falls through. */
+		case 3: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+		case 2: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+		case 1: t = (a[i] - b[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
 		case 0: t = (a[i] - b[i]) - carry; carry = (t >> 63);
 	}
 	return (int)carry;
@@ -325,10 +325,10 @@ lte256_modm_batch(const bignum256modm a,
 	size_t i = 0;
 	bignum256modm_element_t t, carry = 0;
 	switch (limbsize) {
-		case 4: t = (b[i] - a[i])        ; carry = (t >> 63); i++;
-		case 3: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++;
-		case 2: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++;
-		case 1: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++;
+		case 4: t = (b[i] - a[i])        ; carry = (t >> 63); i++; /* Falls through. */
+		case 3: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+		case 2: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
+		case 1: t = (b[i] - a[i]) - carry; carry = (t >> 63); i++; /* Falls through. */
 		case 0: t = (b[i] - a[i]) - carry; carry = (t >> 63);
 	}
 	return (int)!carry;
Index: tor-0.3.0.7/src/or/buffers.c
===================================================================
--- tor-0.3.0.7.orig/src/or/buffers.c	2017-04-24 21:34:15.000000000 +0200
+++ tor-0.3.0.7/src/or/buffers.c	2017-05-31 11:56:22.864546296 +0200
@@ -1710,6 +1710,7 @@ parse_socks(const char *data, size_t dat
           return -1;
       }
       tor_assert(0);
+      break;
     case 4: { /* socks4 */
       enum {socks4, socks4a} socks4_prot = socks4a;
       const char *authstart, *authend;
Index: tor-0.3.0.7/src/or/connection_edge.c
===================================================================
--- tor-0.3.0.7.orig/src/or/connection_edge.c	2017-04-24 21:34:15.000000000 +0200
+++ tor-0.3.0.7/src/or/connection_edge.c	2017-05-31 11:56:22.864546296 +0200
@@ -261,6 +261,7 @@ connection_edge_process_inbuf(edge_conne
       }
       /* Fall through if the connection is on a circuit without optimistic
        * data support. */
+      /* Falls through. */
     case EXIT_CONN_STATE_CONNECTING:
     case AP_CONN_STATE_RENDDESC_WAIT:
     case AP_CONN_STATE_CIRCUIT_WAIT:
Index: tor-0.3.0.7/src/or/dns.c
===================================================================
--- tor-0.3.0.7.orig/src/or/dns.c	2017-04-24 21:34:15.000000000 +0200
+++ tor-0.3.0.7/src/or/dns.c	2017-05-31 11:56:22.864546296 +0200
@@ -522,6 +522,7 @@ send_resolved_cell,(edge_connection_t *c
         answer_type = RESOLVED_TYPE_ERROR;
         /* fall through. */
       }
+      /* Falls through. */
     case RESOLVED_TYPE_ERROR_TRANSIENT:
     case RESOLVED_TYPE_ERROR:
       {
Index: tor-0.3.0.7/src/or/relay.c
===================================================================
--- tor-0.3.0.7.orig/src/or/relay.c	2017-04-24 21:34:15.000000000 +0200
+++ tor-0.3.0.7/src/or/relay.c	2017-05-31 11:56:22.864546296 +0200
@@ -895,6 +895,7 @@ connection_ap_process_end_not_open(
           break; /* break means it'll close, below */
         /* Else fall through: expire this circuit, clear the
          * chosen_exit_name field, and try again. */
+        /* Falls through. */
       case END_STREAM_REASON_RESOLVEFAILED:
       case END_STREAM_REASON_TIMEOUT:
       case END_STREAM_REASON_MISC:
Index: tor-0.3.0.7/src/ext/ed25519/donna/modm-donna-32bit.h
===================================================================
--- tor-0.3.0.7.orig/src/ext/ed25519/donna/modm-donna-32bit.h	2017-03-05 01:44:57.000000000 +0100
+++ tor-0.3.0.7/src/ext/ed25519/donna/modm-donna-32bit.h	2017-05-31 11:56:22.864546296 +0200
@@ -385,14 +385,14 @@ sub256_modm_batch(bignum256modm out, con
 	size_t i = 0;
 	bignum256modm_element_t carry = 0;
 	switch (limbsize) {
-		case 8: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-		case 7: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-		case 6: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-		case 5: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-		case 4: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-		case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-		case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
-		case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++;
+		case 8: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+		case 7: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+		case 6: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+		case 5: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+		case 4: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+		case 3: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+		case 2: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
+		case 1: out[i] = (a[i] - b[i]) - carry; carry = (out[i] >> 31); out[i] &= 0x3fffffff; i++; /* Falls through. */
 		case 0: 
 		default: out[i] = (a[i] - b[i]) - carry;
 	}
@@ -403,14 +403,14 @@ sub256_modm_batch(bignum256modm out, con
 static int
 lt256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize) {
 	switch (limbsize) {
-		case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1;
-		case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1;
-		case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1;
-		case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1;
-		case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1;
-		case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1;
-		case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1;
-		case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1;
+		case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1; /* Falls through. */
+		case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1; /* Falls through. */
+		case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1; /* Falls through. */
+		case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1; /* Falls through. */
+		case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1; /* Falls through. */
+		case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1; /* Falls through. */
+		case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1; /* Falls through. */
+		case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1; /* Falls through. */
 		case 0: if (a[0] > b[0]) return 0; if (a[0] < b[0]) return 1;
 	}
 	return 0;
@@ -420,14 +420,14 @@ lt256_modm_batch(const bignum256modm a,
 static int
 lte256_modm_batch(const bignum256modm a, const bignum256modm b, size_t limbsize) {
 	switch (limbsize) {
-		case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1;
-		case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1;
-		case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1;
-		case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1;
-		case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1;
-		case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1;
-		case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1;
-		case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1;
+		case 8: if (a[8] > b[8]) return 0; if (a[8] < b[8]) return 1; /* Falls through. */
+		case 7: if (a[7] > b[7]) return 0; if (a[7] < b[7]) return 1; /* Falls through. */
+		case 6: if (a[6] > b[6]) return 0; if (a[6] < b[6]) return 1; /* Falls through. */
+		case 5: if (a[5] > b[5]) return 0; if (a[5] < b[5]) return 1; /* Falls through. */
+		case 4: if (a[4] > b[4]) return 0; if (a[4] < b[4]) return 1; /* Falls through. */
+		case 3: if (a[3] > b[3]) return 0; if (a[3] < b[3]) return 1; /* Falls through. */
+		case 2: if (a[2] > b[2]) return 0; if (a[2] < b[2]) return 1; /* Falls through. */
+		case 1: if (a[1] > b[1]) return 0; if (a[1] < b[1]) return 1; /* Falls through. */
 		case 0: if (a[0] > b[0]) return 0; if (a[0] < b[0]) return 1;
 	}
 	return 1;
openSUSE Build Service is sponsored by