Skip to contentSkip to conversation

Documentation: add exception capture function

PATCH In review shijm 3 participants 3 messages Jan 15, 2023 – Jan 19, 2023

Subsystems (3)
lore
Share & tools
lore

shijm

author
#0 lore raw

PATCH 1/1 Documentation: add exception capture function

Add exception capture function

---
 Documentation/target/tcm_mod_builder.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/target/tcm_mod_builder.py +3 -2
index 54492aa813b9..5b28d50ed80f 100755
@@ -29,8 +29,9 @@ def tcm_mod_create_module_subdir(fabric_mod_dir_var):
 		return 1
 
 	print "Creating fabric_mod_dir: " + fabric_mod_dir_var
-	ret = os.mkdir(fabric_mod_dir_var)
-	if ret:
+    try:
+	    ret = os.mkdir(fabric_mod_dir_var)
+	except:
 		tcm_mod_err("Unable to mkdir " + fabric_mod_dir_var)
 
 	return
Signature · 1 line
2.18.2
maintainer
#1 lore raw
Quoted 3 lines · shijm

Add exception capture function

This says what you are doing but not why; nobody has felt the need to mess with this script for a while; why do we need to change it now?

Quoted 8 lines
 Documentation/target/tcm_mod_builder.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/target/tcm_mod_builder.py +0 -0
index 54492aa813b9..5b28d50ed80f 100755

Documentation/target/tcm_mod_builder.py def tcm_mod_create_module_subdir(fabric_mod_dir_var): · line 35

Quoted 9 lines
Documentation/target/tcm_mod_builder.py +3 -2
@@ -29,8 +29,9 @@ def tcm_mod_create_module_subdir(fabric_mod_dir_var):
 		return 1
 
 	print "Creating fabric_mod_dir: " + fabric_mod_dir_var
-	ret = os.mkdir(fabric_mod_dir_var)
-	if ret:
+    try:
+	    ret = os.mkdir(fabric_mod_dir_var)
+	except:
 		tcm_mod_err("Unable to mkdir " + fabric_mod_dir_var)

Bare "except" clauses are generally a bad idea in my exception; I assume you want to catch IOError here?

Assuming that this script is still useful, we should consider moving it to tools/.

Thanks,

jon

#2 lore raw
Quoted 2 lines · Jonathan Corbet

Assuming that this script is still useful, we should consider moving it to tools/.

I'm not sure this script has ever been used after it was added to the kernel tree.

Thanks,

Bart.