chiark / gitweb /
style: util.[ch]: Move doc comments into header file
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Sep 2019 10:51:01 +0000 (11:51 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Sep 2019 10:54:13 +0000 (11:54 +0100)
I think doc comments belong (only) in the header.

Spotted this anomaly during review of 7be31e47b2a8
  "util.[ch]: Factor out hex encoding and decoding utilities."
(although it wasn't introduced there).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
util.c
util.h

diff --git a/util.c b/util.c
index b04b3c6cf6f0a923bc32a830c9cbb8af354f32dc..4729df417c8adb44758591cb46b8ea788d91eebd 100644 (file)
--- a/util.c
+++ b/util.c
@@ -93,7 +93,6 @@ void *safe_malloc_ary(size_t size, size_t count, const char *message) {
     return safe_realloc_ary(0,size,count,message);
 }
 
-/* Hex-encode a buffer, and return the hex in a freshly allocated string. */
 string_t hex_encode(const uint8_t *bin, int binsize)
 {
     char *buff;
@@ -163,7 +162,6 @@ done:
     return ok;
 }
 
-/* Convert a buffer into its MP_INT representation */
 void read_mpbin(MP_INT *a, uint8_t *bin, int binsize)
 {
     char *buff = hex_encode(bin, binsize);
@@ -171,7 +169,6 @@ void read_mpbin(MP_INT *a, uint8_t *bin, int binsize)
     free(buff);
 }
 
-/* Convert a MP_INT into a hex string */
 char *write_mpstring(MP_INT *a)
 {
     char *buff;
@@ -181,7 +178,6 @@ char *write_mpstring(MP_INT *a)
     return buff;
 }
 
-/* Convert a MP_INT into a buffer; return length; truncate if necessary */
 int32_t write_mpbin(MP_INT *a, uint8_t *buffer, int32_t buflen)
 {
     char *hb = write_mpstring(a);
@@ -350,8 +346,6 @@ void *buf_unprepend(struct buffer_if *buf, int32_t amount) {
     return p;
 }
 
-/* Append a two-byte length and the string to the buffer. Length is in
-   network byte order. */
 void buf_append_string(struct buffer_if *buf, cstring_t s)
 {
     size_t len;
diff --git a/util.h b/util.h
index 298f9caecd1e8180f718342c1b4dabb08ca9622d..0a965564ec679a71ea2b5cebc5ff1fc82a37b285 100644 (file)
--- a/util.h
+++ b/util.h
@@ -86,6 +86,8 @@ extern void buffer_readonly_clone(struct buffer_if *n, const struct buffer_if*);
    * it must NOT be freed. */
 
 extern void buf_append_string(struct buffer_if *buf, cstring_t s);
+  /* Append a two-byte length and the string to the buffer. Length is in
+   * network byte order. */
 
 extern string_t hex_encode(const uint8_t *bin, int binsize);
   /* Convert a byte array to hex, returning the result in a freshly allocated
@@ -104,10 +106,13 @@ extern bool_t hex_decode(uint8_t *buffer, int32_t buflen, int32_t *outlen,
    * processed without error; otherwise false. */
 
 extern void read_mpbin(MP_INT *a, uint8_t *bin, int binsize);
+  /* Convert a buffer into its MP_INT representation */
 
 extern char *write_mpstring(MP_INT *a);
+  /* Convert a MP_INT into a hex string */
 
 extern int32_t write_mpbin(MP_INT *a, uint8_t *buffer, int32_t buflen);
+  /* Convert a MP_INT into a buffer; return length; truncate if necessary */
 
 extern struct log_if *init_log(list_t *loglist);