weixin_39828457
weixin_39828457
2020-12-28 02:29

Fixed conversion warnings in zng_tr_tally_dist on Windows

See #440. This uses the same type as zng_tr_tally in trees.c And also the same type zng_tr_tally_dist when ZLIB_DEBUG is defined in deflate.h.

该提问来源于开源项目:zlib-ng/zlib-ng

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

7条回答

  • weixin_39945679 weixin_39945679 4月前

    Codecov Report

    Merging #441 into develop will not change coverage. The diff coverage is n/a.

    Impacted file tree graph

    diff
    @@              Coverage Diff              @@
    ##             develop        #441   +/-   ##
    =============================================
      Coverage   67.86145%   67.86145%           
    =============================================
      Files             44          44           
      Lines           5803        5803           
    =============================================
      Hits            3938        3938           
      Misses          1865        1865
    

    | Impacted Files | Coverage Δ | | |---|---|---| | deflate.h | 100% <ø> (ø) | :arrow_up: |

    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 f29b0e4...4af03a3. Read the comment docs.

    点赞 评论 复制链接分享
  • weixin_39828457 weixin_39828457 4月前

    Sorry I meant "conversion" but typed "signedness". The PR does fix the warnings in #440 even though I botched the terminology. I've updated the issue titles to reflect.

    点赞 评论 复制链接分享
  • weixin_39697096 weixin_39697096 4月前

    There is a reason why we try to avoid using types like "unsigned", "int" and "long" in zlib-ng. Those types don't specify bit width of the variable and such might be slow on one architecture and fast on another. Like I already mentioned earlier, they can also mask other errors in the code due to being pre-standard types, especially "unsigned".

    点赞 评论 复制链接分享
  • weixin_39828457 weixin_39828457 4月前

    I agree it is not ideal to not specify fixed width type, but I am just using the same type as zng_tr_tally. Maybe another PR at a later day can go and clean all the non-fixed width types up.

    点赞 评论 复制链接分享
  • weixin_39868959 weixin_39868959 4月前

    Isn't unsigned char the correct type here? Considering the definition of sym_buf:

    
     unsigned char *sym_buf;
    

    Am I missing something?

    点赞 评论 复制链接分享
  • weixin_39828457 weixin_39828457 4月前

    dist can't be unsigned char because the next line does dist >> 8. I suppose the first assignment automatically does the cast to unsigned char.

    This PR just makes that bit of code the same as this bit of code (as far as casting/types goes): https://github.com/zlib-ng/zlib-ng/blob/edbfb283977a19d1d6c80d78b9d761dd545c8071/trees.c#L736

    点赞 评论 复制链接分享
  • weixin_39697096 weixin_39697096 4月前

    Signedness is same after the change. This is actually case of missing explicit cast in the following lines. When shifting, explicit cast is required by most compilers as shift operator is assuming 32-bit signed integers. Truncating also requires explicit cast.

    点赞 评论 复制链接分享

相关推荐