From bbf4048065cafcc55c186468b0a1cfc1a1bc2236 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 17 Apr 2013 12:40:39 +0200 Subject: no need to pass NULL pointer --- udev-block-notify.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/udev-block-notify.c b/udev-block-notify.c index 44f2f4c..5f1d786 100644 --- a/udev-block-notify.c +++ b/udev-block-notify.c @@ -34,7 +34,9 @@ #define TEXT_DEFAULT "Anything happend to %s (%i:%i)... Don't know." #define TEXT_TAG "\n%s: %s" -char * newstr(char *text, char *notifystr, char *device, unsigned short int major, unsigned short int minor) { +char * newstr(char *text, char *device, unsigned short int major, unsigned short int minor) { + char *notifystr; + notifystr = malloc(strlen(text) + strlen(device) + 10 /* max string length 2* unsigned short int */); sprintf(notifystr, text, device, major, minor); @@ -106,27 +108,27 @@ int main (int argc, char ** argv) { switch(action) { case 'a': // a: add - notifystr = newstr(TEXT_ADD, notifystr, device, major, minor); + notifystr = newstr(TEXT_ADD, device, major, minor); icon = ICON_ADD; break; case 'r': // r: remove - notifystr = newstr(TEXT_REMOVE, notifystr, device, major, minor); + notifystr = newstr(TEXT_REMOVE, device, major, minor); icon = ICON_REMOVE; break; case 'm': // m: move - notifystr = newstr(TEXT_MOVE, notifystr, device, major, minor); + notifystr = newstr(TEXT_MOVE, device, major, minor); icon = ICON_MOVE; break; case 'c': // c: change - notifystr = newstr(TEXT_CHANGE, notifystr, device, major, minor); + notifystr = newstr(TEXT_CHANGE, device, major, minor); icon = ICON_CHANGE; break; default: // we should never get here I think... - notifystr = newstr(TEXT_DEFAULT, notifystr, device, major, minor); + notifystr = newstr(TEXT_DEFAULT, device, major, minor); icon = ICON_DEFAULT; } -- cgit v1.2.3-70-g09d2