]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/udev/ata_id/ata_id.c
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / udev / ata_id / ata_id.c
index 1e414664ce74bc12551fef57ad4711d789be522a..c1367a34f369eb996444da19c088e2bf4fee1aa8 100644 (file)
@@ -1,9 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * ata_id - reads product/serial number from ATA drives
  *
- * Copyright (C) 2005-2008 Kay Sievers <kay@vrfy.org>
- * Copyright (C) 2009 Lennart Poettering <lennart@poettering.net>
- * Copyright (C) 2009-2010 David Zeuthen <zeuthen@gmail.com>
+ * Copyright © 2005-2008 Kay Sievers <kay@vrfy.org>
+ * Copyright © 2009-2010 David Zeuthen <zeuthen@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -317,7 +317,7 @@ static void disk_identify_fixup_uint16 (uint8_t identify[512], unsigned int offs
  * device represented by @fd. If successful, then the result will be
  * copied into @out_identify and @out_is_packet_device.
  *
- * This routine is based on code from libatasmart, Copyright 2008
+ * This routine is based on code from libatasmart, Copyright © 2008
  * Lennart Poettering, LGPL v2.1.
  *
  * Returns: 0 if the data was successfully obtained, otherwise
@@ -404,9 +404,8 @@ out:
         return ret;
 }
 
-int main(int argc, char *argv[])
-{
-        _cleanup_udev_unref_ struct udev *udev = NULL;
+int main(int argc, char *argv[]) {
+        _cleanup_(udev_unrefp) struct udev *udev = NULL;
         struct hd_driveid id;
         union {
                 uint8_t  byte[512];
@@ -427,6 +426,8 @@ int main(int argc, char *argv[])
                 {}
         };
 
+        log_set_target(LOG_TARGET_AUTO);
+        udev_parse_config();
         log_parse_environment();
         log_open();
 
@@ -615,7 +616,7 @@ int main(int argc, char *argv[])
                  */
 
                 word = identify.wyde[76];
-                if (word != 0x0000 && word != 0xffff) {
+                if (!IN_SET(word, 0x0000, 0xffff)) {
                         printf("ID_ATA_SATA=1\n");
                         /*
                          * If bit 2 of word 76 is set to one, then the device supports the Gen2
@@ -659,8 +660,7 @@ int main(int argc, char *argv[])
                 }
 
                 /* from Linux's include/linux/ata.h */
-                if (identify.wyde[0] == 0x848a ||
-                    identify.wyde[0] == 0x844a ||
+                if (IN_SET(identify.wyde[0], 0x848a, 0x844a) ||
                     (identify.wyde[83] & 0xc004) == 0x4004)
                         printf("ID_ATA_CFA=1\n");
         } else {