- dlist_for_each_data(attributes, attr, struct sysfs_attribute) {
- if (attr->value != NULL) {
- strncpy(value, attr->value, SYSFS_VALUE_MAX);
- len = strlen(value);
- if (len == 0)
- continue;
-
- /* remove trailing newline */
- if (value[len-1] == '\n') {
- value[len-1] = '\0';
- len--;
- }
+static void print_all_attributes(struct dlist *attr_list)
+{
+ struct sysfs_attribute *attr;
+ char value[VALUE_SIZE];
+ size_t len;
+
+ dlist_for_each_data(attr_list, attr, struct sysfs_attribute) {
+ if (attr->value == NULL)
+ continue;
+ len = strlcpy(value, attr->value, sizeof(value));
+ if (len >= sizeof(value)) {
+ dbg("attribute value of '%s' too long, skip", attr->name);
+ continue;
+ }