tools: iio: privatize globals and functions in iio_generic_buffer.c file
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Mon, 15 Feb 2021 10:40:42 +0000 (12:40 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 11 Mar 2021 20:47:06 +0000 (20:47 +0000)
Mostly a tidy-up.
But also helps to understand the limits of scope of these functions and
globals.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-24-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
tools/iio/iio_generic_buffer.c

index 34d63bc..7c72405 100644 (file)
@@ -49,7 +49,7 @@ enum autochan {
  * Has the side effect of filling the channels[i].location values used
  * in processing the buffer output.
  **/
-int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
+static int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
 {
        int bytes = 0;
        int i = 0;
@@ -68,7 +68,7 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
        return bytes;
 }
 
-void print1byte(uint8_t input, struct iio_channel_info *info)
+static void print1byte(uint8_t input, struct iio_channel_info *info)
 {
        /*
         * Shift before conversion to avoid sign extension
@@ -85,7 +85,7 @@ void print1byte(uint8_t input, struct iio_channel_info *info)
        }
 }
 
-void print2byte(uint16_t input, struct iio_channel_info *info)
+static void print2byte(uint16_t input, struct iio_channel_info *info)
 {
        /* First swap if incorrect endian */
        if (info->be)
@@ -108,7 +108,7 @@ void print2byte(uint16_t input, struct iio_channel_info *info)
        }
 }
 
-void print4byte(uint32_t input, struct iio_channel_info *info)
+static void print4byte(uint32_t input, struct iio_channel_info *info)
 {
        /* First swap if incorrect endian */
        if (info->be)
@@ -131,7 +131,7 @@ void print4byte(uint32_t input, struct iio_channel_info *info)
        }
 }
 
-void print8byte(uint64_t input, struct iio_channel_info *info)
+static void print8byte(uint64_t input, struct iio_channel_info *info)
 {
        /* First swap if incorrect endian */
        if (info->be)
@@ -167,9 +167,8 @@ void print8byte(uint64_t input, struct iio_channel_info *info)
  *                           to fill the location offsets.
  * @num_channels:      number of channels
  **/
-void process_scan(char *data,
-                 struct iio_channel_info *channels,
-                 int num_channels)
+static void process_scan(char *data, struct iio_channel_info *channels,
+                        int num_channels)
 {
        int k;
 
@@ -238,7 +237,7 @@ static int enable_disable_all_channels(char *dev_dir_name, int enable)
        return 0;
 }
 
-void print_usage(void)
+static void print_usage(void)
 {
        fprintf(stderr, "Usage: generic_buffer [options]...\n"
                "Capture, convert and output data from IIO device buffer\n"
@@ -257,12 +256,12 @@ void print_usage(void)
                "  -w <n>     Set delay between reads in us (event-less mode)\n");
 }
 
-enum autochan autochannels = AUTOCHANNELS_DISABLED;
-char *dev_dir_name = NULL;
-char *buf_dir_name = NULL;
-bool current_trigger_set = false;
+static enum autochan autochannels = AUTOCHANNELS_DISABLED;
+static char *dev_dir_name = NULL;
+static char *buf_dir_name = NULL;
+static bool current_trigger_set = false;
 
-void cleanup(void)
+static void cleanup(void)
 {
        int ret;
 
@@ -294,14 +293,14 @@ void cleanup(void)
        }
 }
 
-void sig_handler(int signum)
+static void sig_handler(int signum)
 {
        fprintf(stderr, "Caught signal %d\n", signum);
        cleanup();
        exit(-signum);
 }
 
-void register_cleanup(void)
+static void register_cleanup(void)
 {
        struct sigaction sa = { .sa_handler = sig_handler };
        const int signums[] = { SIGINT, SIGTERM, SIGABRT };