From 06732c7c7183ff41620a802729d90605ba46d567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 13 Mar 2015 12:38:04 +0100 Subject: [PATCH] addattr: minor cleanup. --- src/bin/addattr/addAttr.cpp | 30 ++++++++++++++---------------- src/bin/addattr/addAttr.h | 7 ++++--- src/bin/addattr/main.cpp | 14 +++++++------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/bin/addattr/addAttr.cpp b/src/bin/addattr/addAttr.cpp index b4ff76516d..5dd1eaa168 100644 --- a/src/bin/addattr/addAttr.cpp +++ b/src/bin/addattr/addAttr.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2004-2015, Axel Dörfler, axeld@pinc-software.de. * Copyright 2002, Sebastian Nozzi. * * Distributed under the terms of the MIT license. @@ -23,7 +23,7 @@ template ssize_t -writeAttrValue(int fd, const char *name, type_code type, Type value) +writeAttrValue(int fd, const char* name, type_code type, Type value) { ssize_t bytes = fs_write_attr(fd, name, type, 0, &value, sizeof(Type)); if (bytes < 0) @@ -33,15 +33,14 @@ writeAttrValue(int fd, const char *name, type_code type, Type value) } -/** Writes an attribute to a node, taking the type into account and - * converting the value accordingly - * - * On success it will return the amount of bytes written - * On failure it returns an error code (negative number) - */ +/*! Writes an attribute to a node, taking the type into account and + converting the value accordingly + On success it will return the amount of bytes written + On failure it returns an error code (negative number) +*/ static ssize_t -writeAttr(int fd, type_code type, const char *name, const char *value, size_t length) +writeAttr(int fd, type_code type, const char* name, const char* value, size_t length) { uint64 uint64value = 0; int64 int64value = 0; @@ -129,15 +128,14 @@ writeAttr(int fd, type_code type, const char *name, const char *value, size_t le } -/** Adds an attribute to a file for the given type, name and value - * Converts the value accordingly in case of numeric or boolean types - * - * On success, it returns B_OK, or else an appropriate error code. - */ +/*! Adds an attribute to a file for the given type, name and value + Converts the value accordingly in case of numeric or boolean types + On success, it returns B_OK, or else an appropriate error code. +*/ status_t -addAttr(const char *file, type_code type, const char *name, - const char *value, size_t length, bool resolveLinks) +addAttr(const char* file, type_code type, const char* name, + const char* value, size_t length, bool resolveLinks) { int fd = open(file, O_RDONLY | (resolveLinks ? 0 : O_NOTRAVERSE)); if (fd < 0) diff --git a/src/bin/addattr/addAttr.h b/src/bin/addattr/addAttr.h index 1190b017c9..d086261f5e 100644 --- a/src/bin/addattr/addAttr.h +++ b/src/bin/addattr/addAttr.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2004-2015, Axel Dörfler, axeld@pinc-software.de. * Copyright 2002, Sebastian Nozzi. * * Distributed under the terms of the MIT license. @@ -11,7 +11,8 @@ #include -status_t addAttr(const char *file, type_code attrType, const char *attrName, - const char *attrValue, size_t length, bool resolveLinks); +status_t addAttr(const char* file, type_code attrType, const char* attrName, + const char* attrValue, size_t length, bool resolveLinks); + #endif /* _ADD_ATTR_H */ diff --git a/src/bin/addattr/main.cpp b/src/bin/addattr/main.cpp index 50c89e1ed6..3d77e5072d 100644 --- a/src/bin/addattr/main.cpp +++ b/src/bin/addattr/main.cpp @@ -1,6 +1,6 @@ /* * Copyright 2010, Jérôme Duval. - * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2004-2015, Axel Dörfler, axeld@pinc-software.de. * Copyright 2002, Sebastian Nozzi. * * Distributed under the terms of the MIT license. @@ -80,7 +80,7 @@ const uint32 kNumSupportedTypes = sizeof(kSupportedTypes) On failure, B_BAD_VALUE is returned and "result" is not modified */ static status_t -typeForString(const char *string, type_code *_result) +typeForString(const char* string, type_code* _result) { for (uint32 i = 0; i < kNumSupportedTypes; i++) { if (!strcmp(string, kSupportedTypes[i].name)) { @@ -134,7 +134,7 @@ invalidAttrType(const char *attrTypeName) void -invalidBoolValue(const char *value) +invalidBoolValue(const char* value) { fprintf(stderr, "%s: attribute value \"%s\" is not valid\n", kProgramName, value); @@ -146,10 +146,10 @@ invalidBoolValue(const char *value) int -main(int argc, char *argv[]) +main(int argc, char* argv[]) { type_code attrType = B_STRING_TYPE; - char *attrValue = NULL; + char* attrValue = NULL; size_t valueFileLength = 0; bool resolveLinks = true; @@ -181,7 +181,7 @@ main(int argc, char *argv[]) " bytes\n", size); return 1; } - attrValue = (char *)malloc(size); + attrValue = (char*)malloc(size); if (attrValue != NULL) status = file.Read(attrValue, size); else @@ -215,7 +215,7 @@ main(int argc, char *argv[]) if (argc - optind < 1) usage(1); - const char *attrName = argv[optind++]; + const char* attrName = argv[optind++]; if (argc - optind < 1) usage(1);