[Dnsmasq-discuss] [PATCH] Make comment style consistent.

Etan Kissling etan.kissling at gmail.com
Thu Jul 22 12:19:11 UTC 2021


Majority of code base does not use C90-style // end of line comments.
This formats the few existing exceptions using /* */ for consistency.
---
NOTE: This builds on top of the other patches that I just submitted.

 src/hash-questions.c | 14 +++++++-------
 src/pattern.c        |  8 ++++----
 src/ubus.c           |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/hash-questions.c b/src/hash-questions.c
index 8e1559f..f41023b 100644
--- a/src/hash-questions.c
+++ b/src/hash-questions.c
@@ -76,9 +76,9 @@ unsigned char *hash_questions(struct dns_header *header, size_t plen, char *name
 
 #else /* HAVE_DNSSEC  || HAVE_CRYPTOHASH */
 
-#define SHA256_BLOCK_SIZE 32            // SHA256 outputs a 32 byte digest
-typedef unsigned char BYTE;             // 8-bit byte
-typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
+#define SHA256_BLOCK_SIZE 32            /* SHA256 outputs a 32 byte digest */
+typedef unsigned char BYTE;             /* 8-bit byte */
+typedef unsigned int  WORD;             /* 32-bit word, change to "long" for 16-bit machines */
 
 typedef struct {
   BYTE data[64];
@@ -238,7 +238,7 @@ static void sha256_final(SHA256_CTX *ctx, BYTE hash[])
   
   i = ctx->datalen;
 
-  // Pad whatever data is left in the buffer.
+  /* Pad whatever data is left in the buffer. */
   if (ctx->datalen < 56)
     {
       ctx->data[i++] = 0x80;
@@ -254,7 +254,7 @@ static void sha256_final(SHA256_CTX *ctx, BYTE hash[])
       memset(ctx->data, 0, 56);
     }
   
-  // Append to the padding the total message's length in bits and transform.
+  /* Append to the padding the total message's length in bits and transform. */
   ctx->bitlen += ctx->datalen * 8;
   ctx->data[63] = ctx->bitlen;
   ctx->data[62] = ctx->bitlen >> 8;
@@ -266,8 +266,8 @@ static void sha256_final(SHA256_CTX *ctx, BYTE hash[])
   ctx->data[56] = ctx->bitlen >> 56;
   sha256_transform(ctx, ctx->data);
   
-  // Since this implementation uses little endian byte ordering and SHA uses big endian,
-  // reverse all the bytes when copying the final state to the output hash.
+  /* Since this implementation uses little endian byte ordering and SHA uses big endian,
+     reverse all the bytes when copying the final state to the output hash. */
   for (i = 0; i < 4; ++i)
     {
       hash[i]      = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
diff --git a/src/pattern.c b/src/pattern.c
index ebcdf16..03e23b9 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -66,8 +66,8 @@ static int is_string_matching_glob_pattern(
 	    pattern_character -= 'a' - 'A';
 	  if (pattern_character == '*')
 	    {
-	      // zero-or-more-character wildcard
-	      // Try to match at value_index, otherwise restart at value_index + 1 next.
+	      /* zero-or-more-character wildcard */
+	      /* Try to match at value_index, otherwise restart at value_index + 1 next. */
 	      next_pattern_index = pattern_index;
 	      pattern_index++;
 	      if (value_index < num_value_bytes)
@@ -78,7 +78,7 @@ static int is_string_matching_glob_pattern(
 	    }
 	  else
 	    {
-	      // ordinary character
+	      /* ordinary character */
 	      if (value_index < num_value_bytes)
 	        {
 		  char value_character = value[value_index];
@@ -249,7 +249,7 @@ int is_valid_dns_name_pattern(const char *value)
   for (const char *c = value;; c++)
     {
       if (*c &&
-	  *c != '*' && // Wildcard.
+	  *c != '*' && /* Wildcard. */
 	  *c != '-' && *c != '.' &&
 	  (*c < '0' || *c > '9') &&
 	  (*c < 'A' || *c > 'Z') &&
diff --git a/src/ubus.c b/src/ubus.c
index f1cd63e..0c502ad 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -84,7 +84,7 @@ static void ubus_destroy(struct ubus_context *ubus)
   ubus_free(ubus);
   daemon->ubus = NULL;
   
-  // Forces re-initialization when we're reusing the same definitions later on.
+  /* Forces re-initialization when we're reusing the same definitions later on. */
   ubus_object.id = 0;
   ubus_object_type.id = 0;
 }
@@ -376,7 +376,7 @@ void ubus_event_bcast_connmark_allowlist_resolved(u32 mark, const char *name, co
   CHECK(blobmsg_add_string(&b, "value", value));
   CHECK(blobmsg_add_u32(&b, "ttl", ttl));
   
-  // Set timeout to allow UBus subscriber to configure firewall rules before returning.
+  /* Set timeout to allow UBus subscriber to configure firewall rules before returning. */
   CHECK(ubus_notify(ubus, &ubus_object, "connmark-allowlist.resolved", b.head, /* timeout: */ 1000));
 }
 #endif
-- 
2.30.1 (Apple Git-130)




More information about the Dnsmasq-discuss mailing list