Skip to content

Commit 320e259

Browse files
PauloMigAlmeidaalexdeucher
authored andcommitted
drm/amdgpu: Replace one-element array with flexible-array member
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct _ATOM_FAKE_EDID_PATCH_RECORD and refactor the rest of the code accordingly. Important to mention is that doing a build before/after this patch results in no binary output differences. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1]. Link: KSPP#79 Link: KSPP#238 Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1] Signed-off-by: Paulo Miguel Almeida <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent c81c5bd commit 320e259

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/gpu/drm/amd/amdgpu/atombios_encoders.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,8 +2081,11 @@ amdgpu_atombios_encoder_get_lcd_info(struct amdgpu_encoder *encoder)
20812081
}
20822082
}
20832083
record += fake_edid_record->ucFakeEDIDLength ?
2084-
fake_edid_record->ucFakeEDIDLength + 2 :
2085-
sizeof(ATOM_FAKE_EDID_PATCH_RECORD);
2084+
struct_size(fake_edid_record,
2085+
ucFakeEDIDString,
2086+
fake_edid_record->ucFakeEDIDLength) :
2087+
/* empty fake edid record must be 3 bytes long */
2088+
sizeof(ATOM_FAKE_EDID_PATCH_RECORD) + 1;
20862089
break;
20872090
case LCD_PANEL_RESOLUTION_RECORD_TYPE:
20882091
panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record;

drivers/gpu/drm/amd/include/atombios.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4107,7 +4107,7 @@ typedef struct _ATOM_FAKE_EDID_PATCH_RECORD
41074107
{
41084108
UCHAR ucRecordType;
41094109
UCHAR ucFakeEDIDLength; // = 128 means EDID length is 128 bytes, otherwise the EDID length = ucFakeEDIDLength*128
4110-
UCHAR ucFakeEDIDString[1]; // This actually has ucFakeEdidLength elements.
4110+
UCHAR ucFakeEDIDString[]; // This actually has ucFakeEdidLength elements.
41114111
} ATOM_FAKE_EDID_PATCH_RECORD;
41124112

41134113
typedef struct _ATOM_PANEL_RESOLUTION_PATCH_RECORD

0 commit comments

Comments
 (0)