Skip to content

Commit e58d680

Browse files
HoyeonRheeekyooo
authored andcommitted
tools: return error code on invalid options
Many tools were exiting with code 0 when given invalid or conflicting options (e.g. mutually exclusive arguments, zero intervals). This patch updates those cases to exit(1), ensuring argument errors propagate as failures to the caller. Signed-off-by: Hoyeon Lee <[email protected]>
1 parent a07d117 commit e58d680

16 files changed

+18
-18
lines changed

tools/biolatency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
if args.flags and args.disks:
6767
print("ERROR: can only use -D or -F. Exiting.")
68-
exit()
68+
exit(1)
6969

7070
# define BPF program
7171
bpf_text = """

tools/btrfsdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
label = "usecs"
5454
if args.interval and int(args.interval) == 0:
5555
print("ERROR: interval 0. Exiting.")
56-
exit()
56+
exit(1)
5757
debug = 0
5858

5959
# define BPF program

tools/cpuunclaimed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def check_runnable_weight_field():
164164
interval = 0.2
165165
if args.interval != -1 and (args.fullcsv or args.csv):
166166
print("ERROR: cannot use interval with either -j or -J. Exiting.")
167-
exit()
167+
exit(1)
168168
if args.interval == -1:
169169
args.interval = "1"
170170
interval = float(args.interval)

tools/criticalstat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
if debugfs_path == "":
5656
print("ERROR: Unable to find debugfs mount point");
57-
sys.exit(0);
57+
sys.exit(1);
5858

5959
trace_path = debugfs_path + b"/tracing/events/preemptirq/";
6060

tools/ext4dist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
label = "usecs"
5454
if args.interval and int(args.interval) == 0:
5555
print("ERROR: interval 0. Exiting.")
56-
exit()
56+
exit(1)
5757
debug = 0
5858

5959
# define BPF program

tools/nfsdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
label = "usecs"
4848
if args.interval and int(args.interval) == 0:
4949
print("ERROR: interval 0. Exiting.")
50-
exit()
50+
exit(1)
5151
debug = 0
5252

5353
# define BPF program

tools/offcputime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def stack_id_err(stack_id):
122122

123123
if args.folded and args.offset:
124124
print("ERROR: can only use -f or -s. Exiting.")
125-
exit()
125+
exit(1)
126126

127127
# signal handler
128128
def signal_ignore(signal, frame):

tools/old/offcputime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
maxdepth = 20 # and MAXDEPTH
5252
if args.pid and args.useronly:
5353
print("ERROR: use either -p or -u.")
54-
exit()
54+
exit(1)
5555

5656
# signal handler
5757
def signal_ignore(signal, frame):

tools/old/offwaketime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
maxtdepth = 20 # and MAXTDEPTH
5656
if args.pid and args.useronly:
5757
print("ERROR: use either -p or -u.")
58-
exit()
58+
exit(1)
5959

6060
# signal handler
6161
def signal_ignore(signal, frame):

tools/old/wakeuptime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
maxdepth = 20 # and MAXDEPTH
5252
if args.pid and args.useronly:
5353
print("ERROR: use either -p or -u.")
54-
exit()
54+
exit(1)
5555

5656
# signal handler
5757
def signal_ignore(signal, frame):

0 commit comments

Comments
 (0)