Insert an explicit cast to silence issue…

In the continuing saga of compiling AOSP 7 for the Samsung Galaxy S4, T-Mobile variant (SGH-M919, JFLTETMO) I ran into an interesting problem. While this used to be a non-issue for building Marshmallow and earlier, libcopybit seems to now have a problem in Nougat. Let’s take a look:

[CODE]
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1390:40: note: insert an explicit cast to silence this issue
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
^~~~~~
static_cast<int>( )
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1390:48: error: non-constant-expression cannot be narrowed from type ‘uint32_t’ (aka ‘unsigned int’) to ‘int’ in initializer list [-Wc++11-narrowing]
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
^~~~~~
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1390:48: note: insert an explicit cast to silence this issue
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
^~~~~~
static_cast<int>( )
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:40: error: non-constant-expression cannot be narrowed from type ‘uint32_t’ (aka ‘unsigned int’) to ‘int’ in initializer list [-Wc++11-narrowing]
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:40: note: insert an explicit cast to silence this issue
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
static_cast<int>( )
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:48: error: non-constant-expression cannot be narrowed from type ‘uint32_t’ (aka ‘unsigned int’) to ‘int’ in initializer list [-Wc++11-narrowing]
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp:1391:48: note: insert an explicit cast to silence this issue
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
^~~~~~
static_cast<int>( )
4 errors generated.
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1
[/CODE]

So, I changed hardware/qcom/display/msm8960/libcopybit/copybit_c2d.cpp from this:

[CODE]
struct copybit_rect_t dr = { 0, 0, dst->w, dst->h };
struct copybit_rect_t sr = { 0, 0, src->w, src->h };
[/CODE]

To this:

[CODE]
struct copybit_rect_t dr = { 0, 0, (int)dst->w, (int)dst->h };
struct copybit_rect_t sr = { 0, 0, (int)src->w, (int)src->h };
[/CODE]

And it compiled sucessfully. Unfortunately, I don’t know how well that fixed the problem (or, if at all), since the AOSP 7 will currently not boot on my S4. But I’ll keep at it!

Linux – keep it simple.

Advertisements

8 thoughts on “Insert an explicit cast to silence issue…

  1. I wish I understood more about this stuff. I just want to mention it is fantastic that sghm919 is still getting attention. It’s a great device. I locked the sim card somehow on mine and have been frustrated at the performance and lack of development for the SM-J320A I foolishly purchased. Long story very short? Thanks

    Like

    1. Thanks for stopping by! Don’t feel bad, I don’t fully understand it all myself! I do agree, however, the S4 is still a great device and deserves a little more attention. Hopefully we can get it upgraded to nougat so this phone can continue to excel!

      Like

  2. I changed from this:

    struct copybit_rect_t dr = { 0, 0, (int)dst->w, (int)dst->h };
    struct copybit_rect_t sr = { 0, 0, (int)src->w, (int)src->h };

    to:

    struct copybit_rect_t dr = { 0, 0, static_cast(dst)->w, static_cast(dst)->h };
    struct copybit_rect_t sr = { 0, 0, static_cast(src)->w, static_cast(src)->h };

    It worked for me by the way. 🙂

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s