Ticket #915: ticket-915.patch
File ticket-915.patch, 5.4 KB (added by , 7 years ago) |
---|
-
atacmds.cpp
339 339 return; 340 340 } 341 341 342 // When using the overloaded swapx() function with member of packed ATA structs, 343 // it is required to pass a possibly unaligned pointer as argument. 344 // Clang++ 4.0 prints -Waddress-of-packed-member warning in this case. 345 // The SWAPV() macro below is a replacement which prevents the use of such pointers. 346 template <typename T> 347 static T get_swapx_val(T x) 348 { swapx(&x); return x; } 349 350 #define SWAPV(x) ((x) = get_swapx_val(x)) 351 342 352 // Invalidate serial number and WWN and adjust checksum in IDENTIFY data 343 353 static void invalidate_serno(ata_identify_device * id) 344 354 { … … 355 365 #ifndef __NetBSD__ 356 366 bool must_swap = !!isbigendian(); 357 367 if (must_swap) 358 swapx(id->words088_255+255-88);368 SWAPV(id->words088_255[255-88]); 359 369 #endif 360 370 if ((id->words088_255[255-88] & 0x00ff) == 0x00a5) 361 371 id->words088_255[255-88] += sum << 8; 362 372 #ifndef __NetBSD__ 363 373 if (must_swap) 364 swapx(id->words088_255+255-88);374 SWAPV(id->words088_255[255-88]); 365 375 #endif 366 376 } 367 377 … … 1001 1011 swap2((char *)&(data->revnumber)); 1002 1012 swap2((char *)&(data->total_time_to_complete_off_line)); 1003 1013 swap2((char *)&(data->smart_capability)); 1004 swapx(&data->extend_test_completion_time_w);1014 SWAPV(data->extend_test_completion_time_w); 1005 1015 for (i=0; i<NUMBER_ATA_SMART_ATTRIBUTES; i++){ 1006 1016 struct ata_smart_attribute *x=data->vendor_attributes+i; 1007 1017 swap2((char *)&(x->flags)); … … 1088 1098 check_multi_sector_sum(log, nsectors, "SMART Extended Self-test Log Structure"); 1089 1099 1090 1100 if (isbigendian()) { 1091 swapx(&log->log_desc_index);1101 SWAPV(log->log_desc_index); 1092 1102 for (unsigned i = 0; i < nsectors; i++) { 1093 1103 for (unsigned j = 0; j < 19; j++) 1094 swapx(&log->log_descs[i].timestamp);1104 SWAPV(log->log_descs[i].timestamp); 1095 1105 } 1096 1106 } 1097 1107 return true; … … 1195 1205 1196 1206 // swap endian order if needed 1197 1207 if (isbigendian()) 1198 swapx(&data->logversion);1208 SWAPV(data->logversion); 1199 1209 1200 1210 return 0; 1201 1211 } … … 1518 1528 check_multi_sector_sum(log, nsectors, "SMART Extended Comprehensive Error Log Structure"); 1519 1529 1520 1530 if (isbigendian()) { 1521 swapx(&log->device_error_count);1522 swapx(&log->error_log_index);1531 SWAPV(log->device_error_count); 1532 SWAPV(log->error_log_index); 1523 1533 for (unsigned i = 0; i < nsectors; i++) { 1524 1534 for (unsigned j = 0; j < 4; j++) { 1525 1535 for (unsigned k = 0; k < 5; k++) 1526 swapx(&log[i].error_logs[j].commands[k].timestamp);1527 swapx(&log[i].error_logs[j].error.timestamp);1536 SWAPV(log[i].error_logs[j].commands[k].timestamp); 1537 SWAPV(log[i].error_logs[j].error.timestamp); 1528 1538 } 1529 1539 } 1530 1540 } … … 2257 2267 2258 2268 // swap endian order if needed 2259 2269 if (isbigendian()){ 2260 swapx(&sts->format_version);2261 swapx(&sts->sct_version);2262 swapx(&sts->sct_spec);2263 swapx(&sts->ext_status_code);2264 swapx(&sts->action_code);2265 swapx(&sts->function_code);2266 swapx(&sts->over_limit_count);2267 swapx(&sts->under_limit_count);2268 swapx(&sts->smart_status);2269 swapx(&sts->min_erc_time);2270 SWAPV(sts->format_version); 2271 SWAPV(sts->sct_version); 2272 SWAPV(sts->sct_spec); 2273 SWAPV(sts->ext_status_code); 2274 SWAPV(sts->action_code); 2275 SWAPV(sts->function_code); 2276 SWAPV(sts->over_limit_count); 2277 SWAPV(sts->under_limit_count); 2278 SWAPV(sts->smart_status); 2279 SWAPV(sts->min_erc_time); 2270 2280 } 2271 2281 2272 2282 // Check format version … … 2299 2309 2300 2310 // swap endian order if needed 2301 2311 if (isbigendian()) { 2302 swapx(&cmd.action_code);2303 swapx(&cmd.function_code);2304 swapx(&cmd.table_id);2312 SWAPV(cmd.action_code); 2313 SWAPV(cmd.function_code); 2314 SWAPV(cmd.table_id); 2305 2315 } 2306 2316 2307 2317 // write command via SMART log page 0xe0 … … 2329 2339 2330 2340 // swap endian order if needed 2331 2341 if (isbigendian()){ 2332 swapx(&tmh->format_version);2333 swapx(&tmh->sampling_period);2334 swapx(&tmh->interval);2335 swapx(&tmh->cb_index);2336 swapx(&tmh->cb_size);2342 SWAPV(tmh->format_version); 2343 SWAPV(tmh->sampling_period); 2344 SWAPV(tmh->interval); 2345 SWAPV(tmh->cb_index); 2346 SWAPV(tmh->cb_size); 2337 2347 } 2338 2348 return 0; 2339 2349 } … … 2366 2376 2367 2377 // swap endian order if needed 2368 2378 if (isbigendian()) { 2369 swapx(&cmd.action_code);2370 swapx(&cmd.function_code);2371 swapx(&cmd.feature_code);2372 swapx(&cmd.state);2373 swapx(&cmd.option_flags);2379 SWAPV(cmd.action_code); 2380 SWAPV(cmd.function_code); 2381 SWAPV(cmd.feature_code); 2382 SWAPV(cmd.state); 2383 SWAPV(cmd.option_flags); 2374 2384 } 2375 2385 2376 2386 // write command via SMART log page 0xe0 … … 2446 2456 2447 2457 // swap endian order if needed 2448 2458 if (isbigendian()) { 2449 swapx(&cmd.action_code);2450 swapx(&cmd.function_code);2451 swapx(&cmd.feature_code);2452 swapx(&cmd.state);2453 swapx(&cmd.option_flags);2459 SWAPV(cmd.action_code); 2460 SWAPV(cmd.function_code); 2461 SWAPV(cmd.feature_code); 2462 SWAPV(cmd.state); 2463 SWAPV(cmd.option_flags); 2454 2464 } 2455 2465 2456 2466 // write command via SMART log page 0xe0 … … 2498 2508 2499 2509 // swap endian order if needed 2500 2510 if (isbigendian()) { 2501 swapx(&cmd.action_code);2502 swapx(&cmd.function_code);2503 swapx(&cmd.selection_code);2504 swapx(&cmd.time_limit);2511 SWAPV(cmd.action_code); 2512 SWAPV(cmd.function_code); 2513 SWAPV(cmd.selection_code); 2514 SWAPV(cmd.time_limit); 2505 2515 } 2506 2516 2507 2517 // write command via SMART log page 0xe0