[Swan-dev] FYI: recent Coverity warnings
Antony Antony
antony at phenome.org
Sat Sep 23 22:13:50 UTC 2017
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)
** CID 1457046: (BAD_SHIFT)
/programs/whack/whack.c: 2114 in main()
/programs/whack/whack.c: 2125 in main()
________________________________________________________________________________________________________
*** CID 1457046: (BAD_SHIFT)
/programs/whack/whack.c: 2114 in main()
2108 {
2109 int ix = enum_match(&debug_names, optarg);
2110 if (ix < 0) {
2111 fprintf(stderr, "whack: unrecognized --debug '%s' option ignored",
2112 optarg);
2113 }
>>> CID 1457046: (BAD_SHIFT)
>>> In expression "1UL << ix", shifting by a negative amount has undefined behavior. The shift amount, "ix", is -1.
2114 msg.debugging |= LELEM(ix);
2115 continue;
2116 }
2117
2118 case DBGOPT_IMPAIR:
2119 {
/programs/whack/whack.c: 2125 in main()
2119 {
2120 int ix = enum_match(&impair_names, optarg);
2121 if (ix < 0) {
2122 fprintf(stderr, "whack: unrecognized --impair '%s' option ignored",
2123 optarg);
2124 }
>>> CID 1457046: (BAD_SHIFT)
>>> In expression "1UL << ix", shifting by a negative amount has undefined behavior. The shift amount, "ix", is -1.
2125 msg.debugging |= LELEM(ix);
2126 continue;
2127 }
2128
2129 default:
2130 /* DBG_* or IMPAIR_* flags */
More information about the Swan-dev
mailing list