@@ -1123,11 +1123,11 @@ static const char * const hibernation_modes[] = {
11231123static ssize_t disk_show (struct kobject * kobj , struct kobj_attribute * attr ,
11241124 char * buf )
11251125{
1126+ ssize_t count = 0 ;
11261127 int i ;
1127- char * start = buf ;
11281128
11291129 if (!hibernation_available ())
1130- return sprintf (buf , "[disabled]\n" );
1130+ return sysfs_emit (buf , "[disabled]\n" );
11311131
11321132 for (i = HIBERNATION_FIRST ; i <= HIBERNATION_MAX ; i ++ ) {
11331133 if (!hibernation_modes [i ])
@@ -1147,12 +1147,16 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
11471147 continue ;
11481148 }
11491149 if (i == hibernation_mode )
1150- buf += sprintf (buf , "[%s] " , hibernation_modes [i ]);
1150+ count += sysfs_emit_at (buf , count , "[%s] " , hibernation_modes [i ]);
11511151 else
1152- buf += sprintf (buf , "%s " , hibernation_modes [i ]);
1152+ count += sysfs_emit_at (buf , count , "%s " , hibernation_modes [i ]);
11531153 }
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 ;
11561160}
11571161
11581162static ssize_t disk_store (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1210,8 +1214,8 @@ power_attr(disk);
12101214static ssize_t resume_show (struct kobject * kobj , struct kobj_attribute * attr ,
12111215 char * buf )
12121216{
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 ));
12151219}
12161220
12171221static ssize_t resume_store (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1270,7 +1274,7 @@ power_attr(resume);
12701274static ssize_t resume_offset_show (struct kobject * kobj ,
12711275 struct kobj_attribute * attr , char * buf )
12721276{
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 );
12741278}
12751279
12761280static ssize_t resume_offset_store (struct kobject * kobj ,
@@ -1293,7 +1297,7 @@ power_attr(resume_offset);
12931297static ssize_t image_size_show (struct kobject * kobj , struct kobj_attribute * attr ,
12941298 char * buf )
12951299{
1296- return sprintf (buf , "%lu\n" , image_size );
1300+ return sysfs_emit (buf , "%lu\n" , image_size );
12971301}
12981302
12991303static ssize_t image_size_store (struct kobject * kobj , struct kobj_attribute * attr ,
@@ -1314,7 +1318,7 @@ power_attr(image_size);
13141318static ssize_t reserved_size_show (struct kobject * kobj ,
13151319 struct kobj_attribute * attr , char * buf )
13161320{
1317- return sprintf (buf , "%lu\n" , reserved_size );
1321+ return sysfs_emit (buf , "%lu\n" , reserved_size );
13181322}
13191323
13201324static ssize_t reserved_size_store (struct kobject * kobj ,
0 commit comments