@@ -1123,11 +1123,11 @@ static const char * const hibernation_modes[] = {
1123
1123
static ssize_t disk_show (struct kobject * kobj , struct kobj_attribute * attr ,
1124
1124
char * buf )
1125
1125
{
1126
+ ssize_t count = 0 ;
1126
1127
int i ;
1127
- char * start = buf ;
1128
1128
1129
1129
if (!hibernation_available ())
1130
- return sprintf (buf , "[disabled]\n" );
1130
+ return sysfs_emit (buf , "[disabled]\n" );
1131
1131
1132
1132
for (i = HIBERNATION_FIRST ; i <= HIBERNATION_MAX ; i ++ ) {
1133
1133
if (!hibernation_modes [i ])
@@ -1147,12 +1147,16 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
1147
1147
continue ;
1148
1148
}
1149
1149
if (i == hibernation_mode )
1150
- buf += sprintf (buf , "[%s] " , hibernation_modes [i ]);
1150
+ count += sysfs_emit_at (buf , count , "[%s] " , hibernation_modes [i ]);
1151
1151
else
1152
- buf += sprintf (buf , "%s " , hibernation_modes [i ]);
1152
+ count += sysfs_emit_at (buf , count , "%s " , hibernation_modes [i ]);
1153
1153
}
1154
- buf += sprintf (buf , "\n" );
1155
- return buf - start ;
1154
+
1155
+ /* Convert the last space to a newline if needed. */
1156
+ if (count > 0 )
1157
+ buf [count - 1 ] = '\n' ;
1158
+
1159
+ return count ;
1156
1160
}
1157
1161
1158
1162
static ssize_t disk_store (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1210,8 +1214,8 @@ power_attr(disk);
1210
1214
static ssize_t resume_show (struct kobject * kobj , struct kobj_attribute * attr ,
1211
1215
char * buf )
1212
1216
{
1213
- return sprintf (buf , "%d:%d\n" , MAJOR (swsusp_resume_device ),
1214
- MINOR (swsusp_resume_device ));
1217
+ return sysfs_emit (buf , "%d:%d\n" , MAJOR (swsusp_resume_device ),
1218
+ MINOR (swsusp_resume_device ));
1215
1219
}
1216
1220
1217
1221
static ssize_t resume_store (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1270,7 +1274,7 @@ power_attr(resume);
1270
1274
static ssize_t resume_offset_show (struct kobject * kobj ,
1271
1275
struct kobj_attribute * attr , char * buf )
1272
1276
{
1273
- return sprintf (buf , "%llu\n" , (unsigned long long )swsusp_resume_block );
1277
+ return sysfs_emit (buf , "%llu\n" , (unsigned long long )swsusp_resume_block );
1274
1278
}
1275
1279
1276
1280
static ssize_t resume_offset_store (struct kobject * kobj ,
@@ -1293,7 +1297,7 @@ power_attr(resume_offset);
1293
1297
static ssize_t image_size_show (struct kobject * kobj , struct kobj_attribute * attr ,
1294
1298
char * buf )
1295
1299
{
1296
- return sprintf (buf , "%lu\n" , image_size );
1300
+ return sysfs_emit (buf , "%lu\n" , image_size );
1297
1301
}
1298
1302
1299
1303
static ssize_t image_size_store (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1314,7 +1318,7 @@ power_attr(image_size);
1314
1318
static ssize_t reserved_size_show (struct kobject * kobj ,
1315
1319
struct kobj_attribute * attr , char * buf )
1316
1320
{
1317
- return sprintf (buf , "%lu\n" , reserved_size );
1321
+ return sysfs_emit (buf , "%lu\n" , reserved_size );
1318
1322
}
1319
1323
1320
1324
static ssize_t reserved_size_store (struct kobject * kobj ,
0 commit comments