Use printf, not sprintf, to print messages to stdout.
Magnus Fromreide
PATCH 1/1 Use printf, not sprintf, to print messages to stdout.
This undos the last printf->sprintf change from 8fd54ace.
--- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/main.cpp +2 -2
@@ -229,7 +229,7 @@ void one_measurement(int seconds, char *workload) void out_of_memory() { reset_display(); - sprintf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting")); + printf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting")); abort(); }
@@ -458,7 +458,7 @@ int main(int argc, char **argv) #ifndef DISABLE_NCURSES endwin(); #endif - sprintf("%s\n", _("Leaving PowerTOP")); + printf("%s\n", _("Leaving PowerTOP")); end_process_data(); clear_process_data();
Signature · 1 line
1.7.10
Magnus Fromreide
Hello!
Could someone please consider the commneted patch?
It stops powertop from crashing on shutdown.
/MF
Sergey Senozhatsky
Quoted 22 lines · Magnus Fromreide
This undos the last
printf->sprintfchange from8fd54ace.Signed-off-by Magnus Fromreide <magfr(a)lysator.liu.se>--- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/main.cpp +1
-1@@ -229,7 +229,7 @@ void one_measurement(int seconds, char *workload) void out_of_memory() { reset_display(); - sprintf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting")); + printf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting")); abort(); }
src/main.cpp int main(int argc, char **argv) · line 464
Quoted 8 lines
src/main.cpp +1
-1@@ -458,7 +458,7 @@ int main(int argc, char **argv) #ifndef DISABLE_NCURSES endwin(); #endif - sprintf("%s\n", _("Leaving PowerTOP")); + printf("%s\n", _("Leaving PowerTOP")); end_process_data(); clear_process_data();
Oh, good catch!
Looks like changes were introduced by commit8fd54ace0a398cd155bf0af620c85d0105778f6a.
-ss
Lekensteyn
Quoted 15 lines · On Thursday 21 June 2012 22:14:41 Sergey Senozhatsky wrote:
Quoted 14 lines · Magnus Fromreide
This undos the last
printf->sprintfchange from8fd54ace.Signed-off-by Magnus Fromreide <magfr(a)lysator.liu.se>---
src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/main.cpp +0
-0@@ -229,7 +229,7 @@ void one_measurement(int seconds, char *workload)
Quoted 6 lines
src/main.cpp void one_measurement(int seconds, char *workload)
Quoted 6 lines
src/main.cpp +0
-1void out_of_memory() { reset_display(); - sprintf("%s...\n",_("PowerTOP is out of memory. PowerTOP is
Aborting"));
Quoted 17 lines
Quoted 17 lines
src/main.cpp +1
-0+ printf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting"));src/main.cpp +1
-1abort(); }@@ -458,7 +458,7 @@ int main(int argc, char **argv) #ifndef DISABLE_NCURSES endwin(); #endif - sprintf("%s\n", _("Leaving PowerTOP")); + printf("%s\n", _("Leaving PowerTOP"));
Quoted 7 lines
src/main.cpp int main(int argc, char **argv) · line 464
Quoted 2 lines
src/main.cpp +0
-0end_process_data(); clear_process_data();Oh, good catch!
Looks like changes were introduced by commit
8fd54ace0a398cd155bf0af620c85d0105778f6a.
That commit contains more abuse of sprintf:
https://github.com/fenrus75/powertop/commit/8fd54ace0a398cd155bf0af620c85d0105778f6a#L1L102
Writing to a constant string is not going to work, eh?
Peter
Magnus Fromreide
Quoted 45 lines · Lekensteyn
Quoted 15 lines · On Thursday 21 June 2012 22:14:41 Sergey Senozhatsky wrote:
Quoted 14 lines · Magnus Fromreide
This undos the last
printf->sprintfchange from8fd54ace.Signed-off-by Magnus Fromreide <magfr(a)lysator.liu.se>---
src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/main.cpp +0
-0@@ -229,7 +229,7 @@ void one_measurement(int seconds, char *workload)Quoted 6 lines
src/main.cpp void one_measurement(int seconds, char *workload)
Quoted 6 lines
src/main.cpp +0
-1void out_of_memory() { reset_display(); - sprintf("%s...\n",_("PowerTOP is out of memory. PowerTOP isAborting"));
Quoted 22 lines
Quoted 9 lines
src/main.cpp +1
-0+ printf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting"));src/main.cpp +0
-0abort(); }@@ -458,7 +458,7 @@ int main(int argc, char **argv) #ifndef DISABLE_NCURSESsrc/main.cpp int main(int argc, char **argv) · line 464
Quoted 10 lines
src/main.cpp +1
-1endwin(); #endif - sprintf("%s\n", _("Leaving PowerTOP")); + printf("%s\n", _("Leaving PowerTOP")); end_process_data(); clear_process_data();Oh, good catch!
Quoted 6 lines
Quoted 2 lines
Looks like changes were introduced by commit
8fd54ace0a398cd155bf0af620c85d0105778f6a.That commit contains more abuse of sprintf:
https://github.com/fenrus75/powertop/commit/8fd54ace0a398cd155bf0af620c85d0105778f6a#L1L102
Writing to a constant string is not going to work, eh?
Yes, lots of sprintf abuse there but most of it is fixed in other patches. I think these are the only ones left.
/MF
Chris Ferron
patch accepted thank you.
Quoted 29 lines · Magnus Fromreide
This undos the last
printf->sprintfchange from8fd54ace.Signed-off-by Magnus Fromreide<magfr(a)lysator.liu.se>--- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/main.cpp +2
-2@@ -229,7 +229,7 @@ void one_measurement(int seconds, char *workload) void out_of_memory() { reset_display(); - sprintf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting")); + printf("%s...\n",_("PowerTOP is out of memory. PowerTOP is Aborting")); abort(); }@@ -458,7 +458,7 @@ int main(int argc, char **argv) #ifndef DISABLE_NCURSES endwin(); #endif - sprintf("%s\n", _("Leaving PowerTOP")); + printf("%s\n", _("Leaving PowerTOP")); end_process_data(); clear_process_data();