Skip to contentSkip to conversation

tools: iio: iio_generic_buffer: -A option code cleanups

PATCH Applied Eva Rachel Retuya 2 participants 5 messages Oct 20, 2016 – Oct 22, 2016 IIO

lore
Share & tools
lore
#0 lore raw

v2 cover tools: iio: iio_generic_buffer: -A option code cleanups

Address Peter's comments:
https://marc.info/?l=linux-iio&m=147673895620791&w=2

Change in v2:
* Update force_autochannels to true/false instead of 1/0.

Eva Rachel Retuya (2):
tools: iio: iio_generic_buffer: rename and change type of force
variable
tools: iio: iio_generic_buffer: drop unneeded parentheses

 tools/iio/iio_generic_buffer.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 tools: iio: iio_generic_buffer: rename and change type of force variable

Replace the type of 'force' flag from int to bool and at the same time rename it to 'force_autochannels' for better readability.

---
 tools/iio/iio_generic_buffer.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tools/iio/iio_generic_buffer.c +5 -4
index 31ddd3a..8ef39ae 100644
@@ -348,7 +348,7 @@ int main(int argc, char **argv)
 	int noevents = 0;
 	int notrigger = 0;
 	char *dummy;
-	int force = 0;
+	bool force_autochannels = false;
 
 	struct iio_channel_info *channels = NULL;
 
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
 			break;
 		case 'A':
 			autochannels = AUTOCHANNELS_ENABLED;
-			force = 1;
+			force_autochannels = true;
 			break;	
 		case 'c':
 			errno = 0;
@@ -526,14 +526,15 @@ int main(int argc, char **argv)
 			"diag %s\n", dev_dir_name);
 		goto error;
 	}
-	if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) && !force) {
+	if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) &&
+	    !force_autochannels) {
 		fprintf(stderr, "Auto-channels selected but some channels "
 			"are already activated in sysfs\n");
 		fprintf(stderr, "Proceeding without activating any channels\n");
 	}
 
 	if ((!num_channels && autochannels == AUTOCHANNELS_ENABLED) ||
-	    ((autochannels == AUTOCHANNELS_ENABLED) && force)) {
+	    ((autochannels == AUTOCHANNELS_ENABLED) && force_autochannels)) {
 		fprintf(stderr, "Enabling all channels\n");
 
 		ret = enable_disable_all_channels(dev_dir_name, 1);
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v2 1/2] tools: iio: iio_generic_buffer: rename and change type of force variable

Quoted 5 lines · Eva Rachel Retuya

Replace the type of 'force' flag from int to bool and at the same time rename it to 'force_autochannels' for better readability.

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 45 lines
---
 tools/iio/iio_generic_buffer.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tools/iio/iio_generic_buffer.c +5 -4
index 31ddd3a..8ef39ae 100644
@@ -348,7 +348,7 @@ int main(int argc, char **argv)
 	int noevents = 0;
 	int notrigger = 0;
 	char *dummy;
-	int force = 0;
+	bool force_autochannels = false;
 
 	struct iio_channel_info *channels = NULL;
 
@@ -362,7 +362,7 @@ int main(int argc, char **argv)
 			break;
 		case 'A':
 			autochannels = AUTOCHANNELS_ENABLED;
-			force = 1;
+			force_autochannels = true;
 			break;	
 		case 'c':
 			errno = 0;
@@ -526,14 +526,15 @@ int main(int argc, char **argv)
 			"diag %s\n", dev_dir_name);
 		goto error;
 	}
-	if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) && !force) {
+	if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) &&
+	    !force_autochannels) {
 		fprintf(stderr, "Auto-channels selected but some channels "
 			"are already activated in sysfs\n");
 		fprintf(stderr, "Proceeding without activating any channels\n");
 	}
 
 	if ((!num_channels && autochannels == AUTOCHANNELS_ENABLED) ||
-	    ((autochannels == AUTOCHANNELS_ENABLED) && force)) {
+	    ((autochannels == AUTOCHANNELS_ENABLED) && force_autochannels)) {
 		fprintf(stderr, "Enabling all channels\n");
 
 		ret = enable_disable_all_channels(dev_dir_name, 1);
#3 lore raw

PATCH v2 2/2 tools: iio: iio_generic_buffer: drop unneeded parentheses

In reply to Eva Rachel Retuya

Remove extra parentheses introduced in commit <73e176a tools: iio:
iio_generic_buffer: add -A to force-enable all channels>.

---
 tools/iio/iio_generic_buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/iio/iio_generic_buffer.c +2 -2
index 8ef39ae..f0c6f54 100644
@@ -526,7 +526,7 @@ int main(int argc, char **argv)
 			"diag %s\n", dev_dir_name);
 		goto error;
 	}
-	if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) &&
+	if (num_channels && autochannels == AUTOCHANNELS_ENABLED &&
 	    !force_autochannels) {
 		fprintf(stderr, "Auto-channels selected but some channels "
 			"are already activated in sysfs\n");
@@ -534,7 +534,7 @@ int main(int argc, char **argv)
 	}
 
 	if ((!num_channels && autochannels == AUTOCHANNELS_ENABLED) ||
-	    ((autochannels == AUTOCHANNELS_ENABLED) && force_autochannels)) {
+	    (autochannels == AUTOCHANNELS_ENABLED && force_autochannels)) {
 		fprintf(stderr, "Enabling all channels\n");
 
 		ret = enable_disable_all_channels(dev_dir_name, 1);
Signature · 1 line
2.7.4
maintainer Applied
#4 lore raw

Re: [PATCH v2 2/2] tools: iio: iio_generic_buffer: drop unneeded parentheses

Quoted 5 lines · Eva Rachel Retuya

Remove extra parentheses introduced in commit <73e176a tools: iio:
iio_generic_buffer: add -A to force-enable all channels>.

Applied, thanks,

Jonathan

Quoted 27 lines
---
 tools/iio/iio_generic_buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/iio/iio_generic_buffer.c +2 -2
index 8ef39ae..f0c6f54 100644
@@ -526,7 +526,7 @@ int main(int argc, char **argv)
 			"diag %s\n", dev_dir_name);
 		goto error;
 	}
-	if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) &&
+	if (num_channels && autochannels == AUTOCHANNELS_ENABLED &&
 	    !force_autochannels) {
 		fprintf(stderr, "Auto-channels selected but some channels "
 			"are already activated in sysfs\n");
@@ -534,7 +534,7 @@ int main(int argc, char **argv)
 	}
 
 	if ((!num_channels && autochannels == AUTOCHANNELS_ENABLED) ||
-	    ((autochannels == AUTOCHANNELS_ENABLED) && force_autochannels)) {
+	    (autochannels == AUTOCHANNELS_ENABLED && force_autochannels)) {
 		fprintf(stderr, "Enabling all channels\n");
 
 		ret = enable_disable_all_channels(dev_dir_name, 1);