From 71136b0bb770d51de5a0de16d83ed14905593693 Mon Sep 17 00:00:00 2001 From: Jonathan L Long Date: Thu, 27 Mar 2014 15:11:17 -0700 Subject: [PATCH 1/2] passing too many args to tool binaries is an error --- tools/convert_imageset.cpp | 2 +- tools/finetune_net.cpp | 2 +- tools/net_speed_benchmark.cpp | 2 +- tools/test_net.cpp | 2 +- tools/train_net.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/convert_imageset.cpp b/tools/convert_imageset.cpp index 4e196d70..219c1310 100644 --- a/tools/convert_imageset.cpp +++ b/tools/convert_imageset.cpp @@ -30,7 +30,7 @@ using std::string; int main(int argc, char** argv) { ::google::InitGoogleLogging(argv[0]); - if (argc < 4) { + if (argc < 4 || argc > 5) { printf("Convert a set of images to the leveldb format used\n" "as input for Caffe.\n" "Usage:\n" diff --git a/tools/finetune_net.cpp b/tools/finetune_net.cpp index 8d25954f..c7e80c94 100644 --- a/tools/finetune_net.cpp +++ b/tools/finetune_net.cpp @@ -14,7 +14,7 @@ using namespace caffe; // NOLINT(build/namespaces) int main(int argc, char** argv) { ::google::InitGoogleLogging(argv[0]); - if (argc < 2) { + if (argc != 3) { LOG(ERROR) << "Usage: finetune_net solver_proto_file pretrained_net"; return 0; } diff --git a/tools/net_speed_benchmark.cpp b/tools/net_speed_benchmark.cpp index db95cc17..bb19b41b 100644 --- a/tools/net_speed_benchmark.cpp +++ b/tools/net_speed_benchmark.cpp @@ -22,7 +22,7 @@ using namespace caffe; // NOLINT(build/namespaces) int main(int argc, char** argv) { int total_iter = 50; - if (argc < 2) { + if (argc < 2 || argc > 5) { LOG(ERROR) << "net_speed_benchmark net_proto [iterations=50]" " [CPU/GPU] [Device_id=0]"; return 0; diff --git a/tools/test_net.cpp b/tools/test_net.cpp index 63922314..75d42d66 100644 --- a/tools/test_net.cpp +++ b/tools/test_net.cpp @@ -17,7 +17,7 @@ using namespace caffe; // NOLINT(build/namespaces) int main(int argc, char** argv) { - if (argc < 4) { + if (argc < 4 || argc > 5) { LOG(ERROR) << "test_net net_proto pretrained_net_proto iterations " << "[CPU/GPU]"; return 0; diff --git a/tools/train_net.cpp b/tools/train_net.cpp index f9516421..bb881d3e 100644 --- a/tools/train_net.cpp +++ b/tools/train_net.cpp @@ -15,7 +15,7 @@ using namespace caffe; // NOLINT(build/namespaces) int main(int argc, char** argv) { ::google::InitGoogleLogging(argv[0]); - if (argc < 2) { + if (argc < 2 || argc > 3) { LOG(ERROR) << "Usage: train_net solver_proto_file [resume_point_file]"; return 0; } From 48cbcb617f91717770d28ee55601bca005b12a68 Mon Sep 17 00:00:00 2001 From: Jonathan L Long Date: Thu, 27 Mar 2014 16:39:05 -0700 Subject: [PATCH 2/2] tools should have nonzero error exit codes --- tools/compute_image_mean.cpp | 2 +- tools/convert_imageset.cpp | 2 +- tools/device_query.cpp | 2 +- tools/finetune_net.cpp | 2 +- tools/net_speed_benchmark.cpp | 2 +- tools/test_net.cpp | 2 +- tools/train_net.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/compute_image_mean.cpp b/tools/compute_image_mean.cpp index b803ab2f..7cf5fe5f 100644 --- a/tools/compute_image_mean.cpp +++ b/tools/compute_image_mean.cpp @@ -18,7 +18,7 @@ int main(int argc, char** argv) { ::google::InitGoogleLogging(argv[0]); if (argc != 3) { LOG(ERROR) << "Usage: compute_image_mean input_leveldb output_file"; - return(0); + return 1; } leveldb::DB* db; diff --git a/tools/convert_imageset.cpp b/tools/convert_imageset.cpp index 219c1310..82edae49 100644 --- a/tools/convert_imageset.cpp +++ b/tools/convert_imageset.cpp @@ -38,7 +38,7 @@ int main(int argc, char** argv) { " RANDOM_SHUFFLE_DATA[0 or 1]\n" "The ImageNet dataset for the training demo is at\n" " http://www.image-net.org/download-images\n"); - return 0; + return 1; } std::ifstream infile(argv[2]); std::vector > lines; diff --git a/tools/device_query.cpp b/tools/device_query.cpp index 6b120ba0..5040b8ee 100644 --- a/tools/device_query.cpp +++ b/tools/device_query.cpp @@ -10,7 +10,7 @@ using namespace caffe; // NOLINT(build/namespaces) int main(int argc, char** argv) { if (argc > 2) { LOG(ERROR) << "device_query [device_id=0]"; - return 0; + return 1; } if (argc == 2) { LOG(INFO) << "Querying device_id=" << argv[1]; diff --git a/tools/finetune_net.cpp b/tools/finetune_net.cpp index c7e80c94..db96b02b 100644 --- a/tools/finetune_net.cpp +++ b/tools/finetune_net.cpp @@ -16,7 +16,7 @@ int main(int argc, char** argv) { ::google::InitGoogleLogging(argv[0]); if (argc != 3) { LOG(ERROR) << "Usage: finetune_net solver_proto_file pretrained_net"; - return 0; + return 1; } SolverParameter solver_param; diff --git a/tools/net_speed_benchmark.cpp b/tools/net_speed_benchmark.cpp index bb19b41b..f52aac9c 100644 --- a/tools/net_speed_benchmark.cpp +++ b/tools/net_speed_benchmark.cpp @@ -25,7 +25,7 @@ int main(int argc, char** argv) { if (argc < 2 || argc > 5) { LOG(ERROR) << "net_speed_benchmark net_proto [iterations=50]" " [CPU/GPU] [Device_id=0]"; - return 0; + return 1; } if (argc >=3) { diff --git a/tools/test_net.cpp b/tools/test_net.cpp index 75d42d66..0abfbf68 100644 --- a/tools/test_net.cpp +++ b/tools/test_net.cpp @@ -20,7 +20,7 @@ int main(int argc, char** argv) { if (argc < 4 || argc > 5) { LOG(ERROR) << "test_net net_proto pretrained_net_proto iterations " << "[CPU/GPU]"; - return 0; + return 1; } cudaSetDevice(0); diff --git a/tools/train_net.cpp b/tools/train_net.cpp index bb881d3e..751a7044 100644 --- a/tools/train_net.cpp +++ b/tools/train_net.cpp @@ -17,7 +17,7 @@ int main(int argc, char** argv) { ::google::InitGoogleLogging(argv[0]); if (argc < 2 || argc > 3) { LOG(ERROR) << "Usage: train_net solver_proto_file [resume_point_file]"; - return 0; + return 1; } SolverParameter solver_param;