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

compilation warnings with -O2 -W -Wall flags #5

Open
xosevp opened this issue Jun 1, 2022 · 0 comments
Open

compilation warnings with -O2 -W -Wall flags #5

xosevp opened this issue Jun 1, 2022 · 0 comments

Comments

@xosevp
Copy link

xosevp commented Jun 1, 2022

gcc version 12.1.1 20220507 (Red Hat 12.1.1-1) (GCC)

cc -g -DFPIN_DEBUG -O2 -W -Wall   -c -o fpin_main.o fpin_main.c
In file included from fpin_main.c:26:
fpin_main.c: In function ‘fpin_fabric_notification_receiver’:
fpin_main.c:93:35: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 3 has type ‘int’ [-Wformat=]
   93 |                         FPIN_ELOG("too short (%zu) to be an FC event", ret);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                        |
      |                                                                        int
fpin.h:33:43: note: in definition of macro ‘FPIN_ELOG’
   33 | #define FPIN_ELOG(fmt...) syslog(LOG_ERR, fmt);
      |                                           ^~~
fpin_main.c:93:49: note: format string is defined here
   93 |                         FPIN_ELOG("too short (%zu) to be an FC event", ret);
      |                                               ~~^
      |                                                 |
      |                                                 long unsigned int
      |                                               %u
fpin_main.c:59:13: warning: unused variable ‘offset’ [-Wunused-variable]
   59 |         int offset =0;
      |             ^~~~~~
fpin_main.c:51:16: warning: unused variable ‘readfs’ [-Wunused-variable]
   51 |         fd_set readfs;
      |                ^~~~~~
fpin_main.c:50:13: warning: unused variable ‘maxfd’ [-Wunused-variable]
   50 |         int maxfd = 0;
      |             ^~~~~
fpin_main.c: In function ‘main’:
fpin_main.c:117:10: warning: unused parameter ‘argc’ [-Wunused-parameter]
  117 | main(int argc, char *argv[])
      |      ~~~~^~~~
fpin_main.c:117:22: warning: unused parameter ‘argv’ [-Wunused-parameter]
  117 | main(int argc, char *argv[])
      |                ~~~~~~^~~~~~
fpin_main.c: At top level:
fpin_main.c:38:12: warning: ‘fcm_fc_socket’ defined but not used [-Wunused-variable]
   38 | static int fcm_fc_socket;
      |            ^~~~~~~~~~~~~
fpin_main.c: In function ‘fpin_fabric_notification_receiver’:
fpin_main.c:96:17: warning: ‘memcpy’ forming offset [2052, 2055] is out of the bounds [0, 2052] [-Warray-bounds]
   96 |                 memcpy(fpin_payload->payload, &(fc_event->event_data), fpin_payload_sz);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -g -DFPIN_DEBUG -O2 -W -Wall   -c -o fpin_els.o fpin_els.c
fpin_els.c: In function ‘fpin_els_extract_wwn’:
fpin_els.c:196:29: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
  196 |         for (iter = 0; iter < wwn_count; iter++) {
      |                             ^
fpin_els.c: In function ‘fpin_process_els_frame’:
fpin_els.c:247:45: warning: unused variable ‘li’ [-Wunused-variable]
  247 |         fpin_link_integrity_notification_t *li = NULL;
      |                                             ^~
cc -g -DFPIN_DEBUG -O2 -W -Wall   -c -o fpin_dm.o fpin_dm.c
In file included from fpin_dm.c:21:
fpin_dm.c: In function ‘fpin_set_rport_marginal’:
fpin_dm.c:108:27: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long unsigned int’ [-Wformat=]
  108 |                 FPIN_DLOG("Got Port Target_buf as %s :%s %d len %d\n",
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  109 |                         target_buf, rport_host_buf, sizeof(rport_host_buf), len);
      |                                                     ~~~~~~~~~~~~~~~~~~~~~~
      |                                                     |
      |                                                     long unsigned int
fpin.h:31:45: note: in definition of macro ‘FPIN_DLOG’
   31 | #define FPIN_DLOG(fmt...) syslog(LOG_DEBUG, fmt);
      |                                             ^~~
fpin_dm.c:108:59: note: format string is defined here
  108 |                 FPIN_DLOG("Got Port Target_buf as %s :%s %d len %d\n",
      |                                                          ~^
      |                                                           |
      |                                                           int
      |                                                          %ld
fpin_dm.c:33:13: warning: unused variable ‘i’ [-Wunused-variable]
   33 |         int i = 0, ret = 0;
      |             ^
fpin_dm.c: In function ‘fpin_insert_sd’:
fpin_dm.c:231:67: warning: unused variable ‘sd_path_len’ [-Wunused-variable]
  231 |         int dev_name_len = 0, sd_node_len = 0, serial_id_len = 0, sd_path_len = 0;
      |                                                                   ^~~~~~~~~~~
fpin_dm.c: In function ‘fpin_dm_insert_target’:
fpin_dm.c:300:27: warning: too many arguments for format [-Wformat-extra-args]
  300 |                 FPIN_ILOG("Inserted target %s and p_wwn into target list\n",
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fpin.h:32:44: note: in definition of macro ‘FPIN_ILOG’
   32 | #define FPIN_ILOG(fmt...) syslog(LOG_INFO, fmt);
      |                                            ^~~
fpin_dm.c: In function ‘fpin_dm_marginal_path’:
fpin_dm.c:582:23: warning: unused variable ‘fd’ [-Wunused-variable]
  582 |         int ret = -1, fd = -1;
      |                       ^~
fpin_dm.c:579:15: warning: unused variable ‘reply’ [-Wunused-variable]
  579 |         char *reply = NULL;
      |               ^~~~~
fpin_dm.c: In function ‘fpin_dm_populate_target’:
fpin_dm.c:792:13: warning: unused variable ‘i’ [-Wunused-variable]
  792 |         int i = 0, ret = 0;
      |             ^
fpin_dm.c: In function ‘fpin_populate_dm_lun’:
fpin_dm.c:978:13: warning: unused variable ‘i’ [-Wunused-variable]
  978 |         int i = 0;
      |             ^
fpin_dm.c:972:13: warning: unused variable ‘wwn_exists’ [-Wunused-variable]
  972 |         int wwn_exists = 0, dm_count = 0;
      |             ^~~~~~~~~~
fpin_dm.c: In function ‘fpin_insert_dm’:
fpin_dm.c:193:25: warning: ‘strncpy’ specified bound 128 equals destination size [-Wstringop-truncation]
  193 |                         strncpy(new_node->dm_uuid, uid_ptr, UUID_LEN);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fpin_dm.c: In function ‘fpin_dm_insert_target’:
fpin_dm.c:299:17: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
  299 |                 strncpy(new_node->p_wwn, port_wwn, WWN_LEN);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘fpin_add_marginal_dev_info’,
    inlined from ‘fpin_dm_marginal_path’ at fpin_dm.c:620:5:
fpin_dm.c:546:17: warning: ‘strncpy’ output may be truncated copying 127 bytes from a string of length 127 [-Wstringop-truncation]
  546 |                 strncpy(newdev->dev_name, devname, (DEV_NAME_LEN - 1));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘fpin_insert_sd’,
    inlined from ‘fpin_populate_dm_lun’ at fpin_dm.c:1059:11:
fpin_dm.c:253:17: warning: ‘strncpy’ specified bound 128 equals destination size [-Wstringop-truncation]
  253 |                 strncpy(new_node->dev_serial_id, serial_id, UUID_LEN);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -g -DFPIN_DEBUG -O2 -W -Wall -o fctxpd fpin_main.o fpin_els.o fpin_dm.o -lpthread -ludev -ldevmapper -lmpathcmd
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

No branches or pull requests

1 participant