mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 18:01:13 +02:00
helpers: improve my_system function
Instead of hardcoding the maximum number of arguments to the my_system helper, pass a variable argument list. The function is deliberately source-incompatible with the old implementation (as opposed to a variant with a sentinel NULL argument, which would be compatible) to find all users and to make sure that new future users of this function are not overlooked during merges with other branches. Signed-off-by: Jacek Jendrzej <crashdvb@googlemail.com>
This commit is contained in:
committed by
Jacek Jendrzej
parent
22be19a9b0
commit
988a8ebec2
@@ -284,10 +284,10 @@ int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&)
|
||||
|
||||
if(hdparm_link){
|
||||
//hdparm -M is not included in busybox hdparm!
|
||||
my_system(hdparm, S_opt, opt);
|
||||
my_system(3, hdparm, S_opt, opt);
|
||||
}else{
|
||||
snprintf(M_opt, sizeof(M_opt),"-M%d", g_settings.hdd_noise);
|
||||
my_system(hdparm, M_opt, S_opt, opt);
|
||||
my_system(4, hdparm, M_opt, S_opt, opt);
|
||||
}
|
||||
free(namelist[i]);
|
||||
}
|
||||
@@ -332,7 +332,7 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key)
|
||||
if(res != CMessageBox::mbrYes)
|
||||
return 0;
|
||||
|
||||
bool srun = my_system("killall", "-9", "smbd");
|
||||
bool srun = my_system(3, "killall", "-9", "smbd");
|
||||
|
||||
//res = check_and_umount(dst);
|
||||
res = check_and_umount(src, dst);
|
||||
@@ -468,7 +468,7 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key)
|
||||
sleep(2);
|
||||
|
||||
printf("CHDDFmtExec: executing %s %s\n","/sbin/tune2fs -r 0 -c 0 -i 0", src);
|
||||
my_system("/sbin/tune2fs", "-r 0", "-c 0", "-i 0", src);
|
||||
my_system(5, "/sbin/tune2fs", "-r 0", "-c 0", "-i 0", src);
|
||||
|
||||
_remount:
|
||||
progress->hide();
|
||||
@@ -502,7 +502,7 @@ _remount:
|
||||
sync();
|
||||
}
|
||||
_return:
|
||||
if(!srun) my_system("smbd",NULL);
|
||||
if (!srun) my_system(1, "smbd");
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ int CHDDChkExec::exec(CMenuTarget* /*parent*/, const std::string& key)
|
||||
|
||||
printf("CHDDChkExec: key %s\n", key.c_str());
|
||||
|
||||
bool srun = my_system("killall", "-9", "smbd");
|
||||
bool srun = my_system(3, "killall", "-9", "smbd");
|
||||
|
||||
//res = check_and_umount(dst);
|
||||
res = check_and_umount(src, dst);
|
||||
@@ -606,6 +606,6 @@ ret1:
|
||||
}
|
||||
printf("CHDDChkExec: mount res %d\n", res);
|
||||
|
||||
if(!srun) my_system("smbd",NULL);
|
||||
if (!srun) my_system(1, "smbd");
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
@@ -3628,7 +3628,7 @@ int CDirMenu::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
if(dirState[number] == DIR_STATE_SERVER_DOWN)
|
||||
{
|
||||
printf("try to start server: %s %s\n","ether-wake", g_settings.network_nfs_mac[dirNfsMountNr[number]]);
|
||||
if(my_system("ether-wake", g_settings.network_nfs_mac[dirNfsMountNr[number]]) != 0)
|
||||
if (my_system(2, "ether-wake", g_settings.network_nfs_mac[dirNfsMountNr[number]]) != 0)
|
||||
perror("ether-wake failed");
|
||||
|
||||
dirOptionText[number]="STARTE SERVER";
|
||||
|
@@ -74,7 +74,7 @@ void CNetworkService::Start()
|
||||
{
|
||||
std::string cmd = command + " " + options;
|
||||
printf("CNetworkService::Start: %s %s\n", command.c_str(), options.c_str());
|
||||
my_system("/bin/sh", "-c", cmd.c_str());
|
||||
my_system(3, "/bin/sh", "-c", cmd.c_str());
|
||||
enabled = true;
|
||||
TouchFile();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void CNetworkService::Stop()
|
||||
{
|
||||
const char killall []= "killall";
|
||||
printf("CNetworkService::Stop: %s %s\n", killall, command.c_str());
|
||||
my_system(killall, command.c_str());
|
||||
my_system(2, killall, command.c_str());
|
||||
enabled = false;
|
||||
TouchFile();
|
||||
}
|
||||
|
@@ -589,7 +589,7 @@ void CPlugins::startPlugin(int number,int /*param*/)
|
||||
g_RCInput->stopInput();
|
||||
//frameBuffer->setMode(720, 576, 8 * sizeof(fb_pixel_t));
|
||||
printf("Starting %s\n", plugin_list[number].pluginfile.c_str());
|
||||
my_system(plugin_list[number].pluginfile.c_str(), NULL, NULL);
|
||||
my_system(2, plugin_list[number].pluginfile.c_str(), NULL);
|
||||
//frameBuffer->setMode(720, 576, 8 * sizeof(fb_pixel_t));
|
||||
frameBuffer->paintBackground();
|
||||
g_RCInput->restartInput();
|
||||
|
@@ -108,7 +108,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
{
|
||||
const char backup_sh[] = "/bin/backup.sh";
|
||||
printf("backup: executing [%s %s]\n",backup_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
||||
my_system( backup_sh, fileBrowser.getSelectedFile()->Name.c_str() );
|
||||
my_system(2, backup_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
||||
}
|
||||
else
|
||||
ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR);
|
||||
@@ -126,7 +126,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
{
|
||||
const char restore_sh[] = "/bin/restore.sh";
|
||||
printf("restore: executing [%s %s]\n", restore_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
||||
my_system( restore_sh, fileBrowser.getSelectedFile()->Name.c_str() );
|
||||
my_system(2, restore_sh, fileBrowser.getSelectedFile()->Name.c_str());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@@ -512,7 +512,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
printf("[update] calling %s %s %s\n",install_sh, g_settings.update_dir, filename.c_str() );
|
||||
#else
|
||||
printf("[update] calling %s %s %s\n",install_sh, g_settings.update_dir, filename.c_str() );
|
||||
my_system( install_sh, g_settings.update_dir, filename.c_str() );
|
||||
my_system(3, install_sh, g_settings.update_dir, filename.c_str());
|
||||
#endif
|
||||
showGlobalStatus(100);
|
||||
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8
|
||||
|
@@ -107,7 +107,7 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str
|
||||
|
||||
if (modus & RESET_UNLOAD) {
|
||||
umount(mountPkt.c_str());
|
||||
my_system("rmmod", mtdramDriver.c_str());
|
||||
my_system(2,"rmmod", mtdramDriver.c_str());
|
||||
}
|
||||
if (modus & RESET_FD1)
|
||||
close(fd1);
|
||||
@@ -231,7 +231,7 @@ bool CExtUpdate::applySettings()
|
||||
// load mtdram driver
|
||||
snprintf(buf1, sizeof(buf1), "total_size=%d", mtdSize/1024);
|
||||
snprintf(buf2, sizeof(buf2), "erase_size=%d", mtdEraseSize/1024);
|
||||
my_system("insmod", mtdramDriver.c_str(), buf1, buf2);
|
||||
my_system(4, "insmod", mtdramDriver.c_str(), buf1, buf2);
|
||||
// check if mtdram driver is now loaded
|
||||
if (!isMtdramLoad())
|
||||
return ErrorReset(0, "error load mtdram driver");
|
||||
|
Reference in New Issue
Block a user