[vim/vim] refactor: remove redundant casts with help of clang-tidy (#8906)

6 views
Skip to first unread message

dundargoc

unread,
Sep 23, 2021, 9:25:02 AM9/23/21
to vim/vim, Subscribed

I used clang-tidy to automatically remove all redundant casts. It uses a compilation database compile_commands.json which was generated with bear. Not even sure if this is a wanted change, just thought I'd try to fix the source of warning messages before suppressing them 👍 . Thanks for your time.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/8906

Commit Summary

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

codecov[bot]

unread,
Sep 23, 2021, 9:33:10 AM9/23/21
to vim/vim, Subscribed

Codecov Report

Merging #8906 (55e6379) into master (56858e4) will decrease coverage by 87.72%.
The diff coverage is 2.54%.

Impacted file tree graph

@@             Coverage Diff             @@

##           master    #8906       +/-   ##

===========================================

- Coverage   90.18%    2.45%   -87.73%     

===========================================

  Files         151      149        -2     

  Lines      170780   165880     -4900     

===========================================

- Hits       154022     4077   -149945     

- Misses      16758   161803   +145045     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.45% <2.54%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/autocmd.c 2.05% <0.00%> (-90.34%) ⬇️
src/blob.c 0.00% <0.00%> (-92.57%) ⬇️
src/buffer.c 3.46% <0.00%> (-88.99%) ⬇️
src/change.c 1.51% <0.00%> (-91.56%) ⬇️
src/channel.c 0.09% <0.00%> (-90.03%) ⬇️
src/charset.c 22.51% <0.00%> (-67.35%) ⬇️
src/clientserver.c 0.00% <0.00%> (-88.39%) ⬇️
src/clipboard.c 5.12% <0.00%> (-78.75%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/debugger.c 0.00% <0.00%> (-96.51%) ⬇️
... and 209 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 56858e4...55e6379. Read the comment docs.

Bram Moolenaar

unread,
Sep 23, 2021, 1:11:49 PM9/23/21
to vim/vim, Subscribed

Removing redundant type casts is nice, keeps the code clean.
It does appear to be incorrect in a few places though. Consider this one:

  •       n = (long)(p - t) - stl_items[stl_groupitem[groupdepth]]
    
  •       n = (p - t) - stl_items[stl_groupitem[groupdepth]]
    

subtracting two pointers results in size_t and "n" is a long. I would think the type cast is
still needed here. Try this on MS-Windows, which is the most picky about the difference
between size_t and integers. I believe size_t is 64 bits and long is 32 bits. Resulting in this error:

buffer.c(4403): warning C4267: '=': conversion from 'size_t' to 'long', possible loss of data

dundargoc

unread,
Sep 23, 2021, 1:35:47 PM9/23/21
to vim/vim, Subscribed

Aha. Figured it'd be too easy :). I didn't consider windows. Thanks for the explanation.

I'll go back to the drawing board and test on windows as well. Closing for now.

dundargoc

unread,
Sep 23, 2021, 1:36:32 PM9/23/21
to vim/vim, Subscribed

Closed #8906.

Reply all
Reply to author
Forward
0 new messages