Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix small warnings #170

Merged
merged 7 commits into from
Sep 13, 2021
Merged

Conversation

kenji-miyake
Copy link

I fixed some warnings.

I put the before/after results below.
Note There are some errors left, so I ignored some options.

  add_compile_options(-Wall -Wextra -Wpedantic -Wno-overflow -Wno-deprecated-declarations -Wno-switch)

Before(aa937b7)

~/ghq/github.com/ros-drivers/usb_cam ros2*
❯ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 
Starting >>> usb_cam 
--- stderr: usb_cam                              
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp:126:3: warning: multi-line comment [-Wcomment]
  126 |   //     "mjpeg2rgb " << len << ", image 0x" << std::hex << (unsigned long int)RGB \
      |   ^
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp:172:3: warning: multi-line comment [-Wcomment]
  172 |   //   rclcpp::get_logger("usb_cam"), "sw scaler " << xsize << " " << ysize << " " \
      |   ^
In file included from /home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp:31:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam.hpp: In constructor ‘usb_cam::UsbCam::UsbCam()’:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam.hpp:167:20: warning: ‘usb_cam::UsbCam::image_’ will be initialized after [-Wreorder]
  167 |   camera_image_t * image_;
      |                    ^~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam.hpp:148:8: warning:   ‘bool usb_cam::UsbCam::is_capturing_’ [-Wreorder]
  148 |   bool is_capturing_;
      |        ^~~~~~~~~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp:63:1: warning:   when initialized here [-Wreorder]
   63 | UsbCam::UsbCam()
      | ^~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::mjpeg2rgb(char*, int, char*, int)’:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp:122:63: warning: unused parameter ‘NumPixels’ [-Wunused-parameter]
  122 | bool UsbCam::mjpeg2rgb(char * MJPEG, int len, char * RGB, int NumPixels)
      |                                                           ~~~~^~~~~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::init_device(int, int, int)’:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp:738:7: warning: suggest parentheses around operand of ‘!’ or change ‘&’ to ‘&&’ or ‘!’ to ‘~’ [-Wparentheses]
  738 |   if (!stream_params.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) {
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp: In member function ‘bool usb_cam::UsbCam::set_v4l_parameter(const string&, const string&)’:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam.cpp:1083:1: warning: no return statement in function returning non-void [-Wreturn-type]
 1083 | }
      | ^
In file included from /opt/ros/galactic/include/rclcpp/client.hpp:40,
                 from /opt/ros/galactic/include/rclcpp/callback_group.hpp:23,
                 from /opt/ros/galactic/include/rclcpp/any_executable.hpp:20,
                 from /opt/ros/galactic/include/rclcpp/memory_strategy.hpp:25,
                 from /opt/ros/galactic/include/rclcpp/memory_strategies.hpp:18,
                 from /opt/ros/galactic/include/rclcpp/executor_options.hpp:20,
                 from /opt/ros/galactic/include/rclcpp/executor.hpp:36,
                 from /opt/ros/galactic/include/rclcpp/executors/multi_threaded_executor.hpp:26,
                 from /opt/ros/galactic/include/rclcpp/executors.hpp:21,
                 from /opt/ros/galactic/include/rclcpp/rclcpp.hpp:156,
                 from /home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam.hpp:51,
                 from /home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam_node.hpp:32,
                 from /home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam_node.cpp:30:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam_node.cpp: In member function ‘void usb_cam::UsbCamNode::get_params()’:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam_node.cpp:178:39: warning: format ‘%s’ expects argument of type ‘char*’, but argument 5 has type ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} [-Wformat=]
  178 |       RCLCPP_WARN(this->get_logger(), "Invalid parameter name: %s", parameter.get_name());
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam_node.cpp:178:65: note: format string is defined here
  178 |       RCLCPP_WARN(this->get_logger(), "Invalid parameter name: %s", parameter.get_name());
      |                                                                ~^
      |                                                                 |
      |                                                                 char*
In file included from /home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam.hpp:32,
                 from /home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam_node.hpp:32,
                 from /home/kenji/ghq/github.com/ros-drivers/usb_cam/src/usb_cam_node.cpp:30:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam_utils.hpp: At global scope:
/home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam_utils.hpp:339:13: warning: ‘bool usb_cam::yuyv2rgb(char*, char*, int)’ defined but not used [-Wunused-function]
  339 | static bool yuyv2rgb(char * YUV, char * RGB, int NumPixels)
      |             ^~~~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam_utils.hpp:329:13: warning: ‘bool usb_cam::mono102mono8(char*, char*, int)’ defined but not used [-Wunused-function]
  329 | static bool mono102mono8(char * RAW, char * MONO, int NumPixels)
      |             ^~~~~~~~~~~~
/home/kenji/ghq/github.com/ros-drivers/usb_cam/include/usb_cam/usb_cam_utils.hpp:70:12: warning: ‘int usb_cam::xioctl(int, int, void*)’ defined but not used [-Wunused-function]
   70 | static int xioctl(int fd, int request, void * arg)
      |            ^~~~~~
---
Finished <<< usb_cam [10.6s]

Summary: 1 package finished [10.7s]
  1 package had stderr output: usb_cam

After

~/ghq/github.com/ros-drivers/usb_cam fix-small-warnings*
❯ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 
Starting >>> usb_cam 
Finished <<< usb_cam [4.61s]                     

Summary: 1 package finished [4.72s]

Kenji Miyake added 7 commits September 13, 2021 00:35
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@flynneva
Copy link
Collaborator

@kenji-miyake awesome stuff here! looks great so far, I'll let the CI run and do a more in depth look early tomorrow.

I think this might tackle a lot (maybe all) of the warnings referenced by #152 as well?

@kenji-miyake
Copy link
Author

@flynneva Thank you!

I think this might tackle a lot (maybe all) of the warnings referenced by #152 as well?

Unfortunately, no. They were ignored here.

  add_compile_options(-Wall -Wextra -Wpedantic -Wno-overflow -Wno-deprecated-declarations -Wno-switch)

They were avcodec_register_all, avpicture_alloc, and other av-related warnings.
Since it's a bit difficult for me, not in the scope of this PR.

@flynneva flynneva merged commit 1faffe1 into ros-drivers:ros2 Sep 13, 2021
@kenji-miyake kenji-miyake deleted the fix-small-warnings branch September 13, 2021 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants