Message ID | 20230307134245.83599-1-bchihi@baylibre.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | thermal/drivers/mediatek/lvts_thermal: fix memcpy's number of bytes in lvts_calibration_init() | expand |
Il 07/03/23 14:42, bchihi@baylibre.com ha scritto: > From: Balsam CHIHI <bchihi@baylibre.com> > > Replace memcpy 2 bytes by sizeof(int) bytes of LVTS calibration data. sizeof(int) is architecture dependant... please use a fixed size type instead. Also, shouldn't this be u16?! Regards, Angelo
On Wed, Mar 08, 2023 at 10:10:34AM +0100, AngeloGioacchino Del Regno wrote: > Il 07/03/23 14:42, bchihi@baylibre.com ha scritto: > > From: Balsam CHIHI <bchihi@baylibre.com> > > > > Replace memcpy 2 bytes by sizeof(int) bytes of LVTS calibration data. > > sizeof(int) is architecture dependant... > On Linux sizeof(int) is always 4. I'm just so confused what you are talking about. Are you thinking about sizeof(long)? Are you thinking about CPUs from the 1970s? Linux wasn't invented until the 90s so the old CPUs were already in museums at that point. > please use a fixed size type instead. This is an unusual style opinion that I have not heard before. Hopefully, you just got ints and longs confused so we can move on without discussing it too much. We're copying an int so sizeof(int) is obviously correct. It's hard to know how to respond. > Also, shouldn't this be u16?! What? Why would you think that? regards, dan carpenter
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c index ddfdcbcf6d86..b505c6b49031 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -575,7 +575,7 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++) memcpy(&lvts_ctrl->calibration[i], - efuse_calibration + lvts_ctrl_data->cal_offset[i], 2); + efuse_calibration + lvts_ctrl_data->cal_offset[i], sizeof(int)); return 0; }