Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavrth committed Oct 11, 2023
1 parent cd0009c commit 762b2c5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
5 changes: 3 additions & 2 deletions examples/describe_topics.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ static void print_topic_info(const rd_kafka_TopicDescription_t *topic) {
size_t authorized_operations_cnt;
const rd_kafka_TopicPartitionInfo_t **partitions;
size_t partition_cnt;
const rd_kafka_Uuid_t *topic_id = rd_kafka_TopicDescription_topic_id(topic);
const char *topic_id_str = rd_kafka_Uuid_base64str(topic_id);
const rd_kafka_Uuid_t *topic_id =
rd_kafka_TopicDescription_topic_id(topic);
const char *topic_id_str = rd_kafka_Uuid_base64str(topic_id);

if (rd_kafka_error_code(error)) {
printf("Topic: %s (Topic Id: %s) has error[%" PRId32 "]: %s\n",
Expand Down
13 changes: 7 additions & 6 deletions src/rdbase64.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@
#include <openssl/ssl.h>
#else

# define conv_bin2ascii(a, table) ((table)[(a)&0x3f])
#define conv_bin2ascii(a, table) ((table)[(a)&0x3f])

static const unsigned char data_bin2ascii[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

static int base64_encoding_conversion(unsigned char *out,
const unsigned char *in,
int dlen)
{
int dlen) {
int i, ret = 0;
unsigned long l;

Expand All @@ -59,7 +58,9 @@ static int base64_encoding_conversion(unsigned char *out,

*(out++) = conv_bin2ascii(l >> 18L, data_bin2ascii);
*(out++) = conv_bin2ascii(l >> 12L, data_bin2ascii);
*(out++) = (i == 1) ? '=' : conv_bin2ascii(l >> 6L, data_bin2ascii);
*(out++) =
(i == 1) ? '='
: conv_bin2ascii(l >> 6L, data_bin2ascii);
*(out++) = '=';
}
ret += 4;
Expand Down Expand Up @@ -96,8 +97,8 @@ void rd_base64_encode(const rd_chariov_t *in, rd_chariov_t *out) {
out->size = EVP_EncodeBlock((unsigned char *)out->ptr,
(unsigned char *)in->ptr, (int)in->size);
#else
out->size = base64_encoding_conversion((unsigned char *)out->ptr,
(unsigned char *)in->ptr, (int)in->size);
out->size = base64_encoding_conversion(
(unsigned char *)out->ptr, (unsigned char *)in->ptr, (int)in->size);
#endif

rd_assert(out->size < max_len);
Expand Down
2 changes: 1 addition & 1 deletion src/rdkafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -5087,7 +5087,7 @@ const char *rd_kafka_Uuid_base64str(const rd_kafka_Uuid_t *uuid) {
if (!out_base64_str)
return NULL;

rd_strlcpy((char *) uuid->base64str, out_base64_str,
rd_strlcpy((char *)uuid->base64str, out_base64_str,
23 /* Removing extra ('=') padding */);
rd_free(out_base64_str);
return uuid->base64str;
Expand Down
6 changes: 4 additions & 2 deletions src/rdkafka.h
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,8 @@ RD_EXPORT const char *rd_kafka_Uuid_base64str(const rd_kafka_Uuid_t *uuid);
*
* @return least significant 64 bits for the given UUID.
*/
RD_EXPORT int64_t rd_kafka_Uuid_least_significant_bits(const rd_kafka_Uuid_t *uuid);
RD_EXPORT int64_t
rd_kafka_Uuid_least_significant_bits(const rd_kafka_Uuid_t *uuid);


/**
Expand All @@ -1664,7 +1665,8 @@ RD_EXPORT int64_t rd_kafka_Uuid_least_significant_bits(const rd_kafka_Uuid_t *uu
*
* @return most significant 64 bits for the given UUID.
*/
RD_EXPORT int64_t rd_kafka_Uuid_most_significant_bits(const rd_kafka_Uuid_t *uuid);
RD_EXPORT int64_t
rd_kafka_Uuid_most_significant_bits(const rd_kafka_Uuid_t *uuid);


/**
Expand Down
6 changes: 3 additions & 3 deletions src/rdkafka_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ struct rd_kafka_TopicPartitionInfo_s {
* @struct DescribeTopics result
*/
struct rd_kafka_TopicDescription_s {
char *topic; /**< Topic name */
char *topic; /**< Topic name */
rd_kafka_Uuid_t topic_id; /**< Topic Id */
int partition_cnt; /**< Number of partitions in \p partitions*/
rd_bool_t is_internal; /**< Is the topic is internal to Kafka? */
int partition_cnt; /**< Number of partitions in \p partitions*/
rd_bool_t is_internal; /**< Is the topic is internal to Kafka? */
rd_kafka_TopicPartitionInfo_t **partitions; /**< Partitions */
rd_kafka_error_t *error; /**< Topic error reported by broker */
int authorized_operations_cnt; /**< Count of operations allowed for
Expand Down

0 comments on commit 762b2c5

Please sign in to comment.