@@ -2126,19 +2126,23 @@ static char *json_eom_printable_eye(struct nvme_eom_lane_desc *lane,
21262126 char * eye = (char * )lane -> eye_desc ;
21272127 uint16_t nrows = le16_to_cpu (lane -> nrows );
21282128 uint16_t ncols = le16_to_cpu (lane -> ncols );
2129+ char * printable = NULL ;
2130+ char * printable_start = NULL ;
2131+ struct json_object * eye_array = json_create_array ();
21292132
21302133 if (nrows == 0 || ncols == 0 )
21312134 return NULL ;
21322135
2133- // Allocate buffer for full printable string (with newlines)
2134- char * printable = malloc (nrows * ncols + nrows + 1 ); // +1 for null terminator
2135- char * printable_start = printable ;
2136+ /*
2137+ * Allocate buffer for full printable string (with newlines)
2138+ * +1 for null terminator
2139+ */
2140+ printable = malloc (nrows * ncols + nrows + 1 );
2141+ printable_start = printable ;
21362142
21372143 if (!printable )
21382144 return NULL ;
21392145
2140- struct json_object * eye_array = json_create_array ();
2141-
21422146 if (!eye_array ) {
21432147 free (printable );
21442148 return NULL ;
@@ -2148,7 +2152,7 @@ static char *json_eom_printable_eye(struct nvme_eom_lane_desc *lane,
21482152 char * row = malloc (ncols + 1 );
21492153
21502154 if (!row ) {
2151- // Cleanup on failure
2155+ /* Cleanup on failure */
21522156 free (printable_start );
21532157 return NULL ;
21542158 }
@@ -2188,6 +2192,9 @@ static void json_phy_rx_eom_descs(struct nvme_phy_rx_eom_log *log,
21882192 unsigned char * vsdata = NULL ;
21892193 unsigned int vsdataoffset = 0 ;
21902194 struct json_object * jdesc = json_create_object ();
2195+ uint16_t nrows = le16_to_cpu (desc -> nrows );
2196+ uint16_t ncols = le16_to_cpu (desc -> ncols );
2197+ uint16_t edlen = le16_to_cpu (desc -> edlen );
21912198
21922199 obj_add_uint (jdesc , "lid" , desc -> mstatus );
21932200 obj_add_uint (jdesc , "lane" , desc -> lane );
@@ -2196,31 +2203,32 @@ static void json_phy_rx_eom_descs(struct nvme_phy_rx_eom_log *log,
21962203 obj_add_uint (jdesc , "bottom" , le16_to_cpu (desc -> bottom ));
21972204 obj_add_uint (jdesc , "left" , le16_to_cpu (desc -> left ));
21982205 obj_add_uint (jdesc , "right" , le16_to_cpu (desc -> right ));
2199- obj_add_uint (jdesc , "nrows" , le16_to_cpu ( desc -> nrows ) );
2200- obj_add_uint (jdesc , "ncols" , le16_to_cpu ( desc -> ncols ) );
2201- obj_add_uint (jdesc , "edlen" , le16_to_cpu ( desc -> edlen ) );
2206+ obj_add_uint (jdesc , "nrows" , nrows );
2207+ obj_add_uint (jdesc , "ncols" , ncols );
2208+ obj_add_uint (jdesc , "edlen" , edlen );
22022209
22032210 if (NVME_EOM_ODP_PEFP (log -> odp ))
22042211 allocated_eyes [i ] = json_eom_printable_eye (desc , jdesc );
22052212
2206- if (desc -> edlen == 0 )
2213+ if (edlen == 0 )
22072214 continue ;
22082215
2209- /* Hex dump Vendor Specific Eye Data*/
2210- vsdataoffset = (le16_to_cpu (desc -> nrows ) * le16_to_cpu (desc -> ncols )) +
2211- sizeof (struct nvme_eom_lane_desc );
2212- vsdata = (unsigned char * )((unsigned char * )desc + vsdataoffset );
2213- // 2 hex chars + space per byte
2214- _cleanup_free_ char * hexstr = malloc (le16_to_cpu (desc -> edlen ) * 3 + 1 );
2216+ /* 2 hex chars + space per byte */
2217+ _cleanup_free_ char * hexstr = malloc (edlen * 3 + 1 );
22152218
22162219 if (!hexstr )
22172220 return ;
22182221
2222+ /* Hex dump Vendor Specific Eye Data */
2223+ vsdataoffset = (nrows * ncols ) + sizeof (struct nvme_eom_lane_desc );
2224+ vsdata = (unsigned char * )((unsigned char * )desc + vsdataoffset );
2225+
22192226 char * hexdata = hexstr ;
22202227
2221- for (int offset = 0 ; offset < le16_to_cpu ( desc -> edlen ) ; offset ++ )
2228+ for (int offset = 0 ; offset < edlen ; offset ++ )
22222229 hexdata += sprintf (hexdata , "%02X " , vsdata [offset ]);
2223- * (hexdata - 1 ) = '\0' ; // remove trailing space
2230+ /* remove trailing space */
2231+ * (hexdata - 1 ) = '\0' ;
22242232
22252233 obj_add_str (jdesc , "vsdata_hex" , hexstr );
22262234
0 commit comments