mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-14 06:59:53 -05:00
remaining s/assert/pa_assert/ and refcnt.h modernizations
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1809 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
2988c3d9fb
commit
d5bedbcd98
59 changed files with 967 additions and 724 deletions
|
|
@ -26,7 +26,6 @@
|
|||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
|
|
@ -36,6 +35,7 @@
|
|||
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/strbuf.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "cmdline.h"
|
||||
|
||||
|
|
@ -100,6 +100,8 @@ static struct option long_options[] = {
|
|||
void pa_cmdline_help(const char *argv0) {
|
||||
const char *e;
|
||||
|
||||
pa_assert(argv0);
|
||||
|
||||
if ((e = strrchr(argv0, '/')))
|
||||
e++;
|
||||
else
|
||||
|
|
@ -154,7 +156,10 @@ void pa_cmdline_help(const char *argv0) {
|
|||
int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d) {
|
||||
pa_strbuf *buf = NULL;
|
||||
int c;
|
||||
assert(conf && argc && argv);
|
||||
|
||||
pa_assert(conf);
|
||||
pa_assert(argc > 0);
|
||||
pa_assert(argv);
|
||||
|
||||
buf = pa_strbuf_new();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "cpulimit.h"
|
||||
|
||||
|
|
@ -38,7 +39,6 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
|
@ -92,23 +92,18 @@ static enum {
|
|||
|
||||
/* Reset the SIGXCPU timer to the next t seconds */
|
||||
static void reset_cpu_time(int t) {
|
||||
int r;
|
||||
long n;
|
||||
struct rlimit rl;
|
||||
struct rusage ru;
|
||||
|
||||
/* Get the current CPU time of the current process */
|
||||
r = getrusage(RUSAGE_SELF, &ru);
|
||||
assert(r >= 0);
|
||||
pa_assert_se(getrusage(RUSAGE_SELF, &ru) >= 0);
|
||||
|
||||
n = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec + t;
|
||||
|
||||
r = getrlimit(RLIMIT_CPU, &rl);
|
||||
assert(r >= 0);
|
||||
pa_assert_se(getrlimit(RLIMIT_CPU, &rl) >= 0);
|
||||
|
||||
rl.rlim_cur = n;
|
||||
r = setrlimit(RLIMIT_CPU, &rl);
|
||||
assert(r >= 0);
|
||||
pa_assert_se(setrlimit(RLIMIT_CPU, &rl) >= 0);
|
||||
}
|
||||
|
||||
/* A simple, thread-safe puts() work-alike */
|
||||
|
|
@ -118,7 +113,7 @@ static void write_err(const char *p) {
|
|||
|
||||
/* The signal handler, called on every SIGXCPU */
|
||||
static void signal_handler(int sig) {
|
||||
assert(sig == SIGXCPU);
|
||||
pa_assert(sig == SIGXCPU);
|
||||
|
||||
if (phase == PHASE_IDLE) {
|
||||
time_t now;
|
||||
|
|
@ -160,7 +155,12 @@ static void signal_handler(int sig) {
|
|||
/* Callback for IO events on the FIFO */
|
||||
static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags_t f, void *userdata) {
|
||||
char c;
|
||||
assert(m && e && f == PA_IO_EVENT_INPUT && e == io_event && fd == the_pipe[0]);
|
||||
pa_assert(m);
|
||||
pa_assert(e);
|
||||
pa_assert(f == PA_IO_EVENT_INPUT);
|
||||
pa_assert(e == io_event);
|
||||
pa_assert(fd == the_pipe[0]);
|
||||
|
||||
pa_read(the_pipe[0], &c, sizeof(c), NULL);
|
||||
m->quit(m, 1); /* Quit the main loop */
|
||||
}
|
||||
|
|
@ -168,7 +168,13 @@ static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags
|
|||
/* Initializes CPU load limiter */
|
||||
int pa_cpu_limit_init(pa_mainloop_api *m) {
|
||||
struct sigaction sa;
|
||||
assert(m && !api && !io_event && the_pipe[0] == -1 && the_pipe[1] == -1 && !installed);
|
||||
|
||||
pa_assert(m);
|
||||
pa_assert(!api);
|
||||
pa_assert(!io_event);
|
||||
pa_assert(the_pipe[0] == -1);
|
||||
pa_assert(the_pipe[1] == -1);
|
||||
pa_assert(!installed);
|
||||
|
||||
time(&last_time);
|
||||
|
||||
|
|
@ -208,10 +214,9 @@ int pa_cpu_limit_init(pa_mainloop_api *m) {
|
|||
|
||||
/* Shutdown CPU load limiter */
|
||||
void pa_cpu_limit_done(void) {
|
||||
int r;
|
||||
|
||||
if (io_event) {
|
||||
assert(api);
|
||||
pa_assert(api);
|
||||
api->io_free(io_event);
|
||||
io_event = NULL;
|
||||
api = NULL;
|
||||
|
|
@ -224,8 +229,7 @@ void pa_cpu_limit_done(void) {
|
|||
the_pipe[0] = the_pipe[1] = -1;
|
||||
|
||||
if (installed) {
|
||||
r = sigaction(SIGXCPU, &sigaction_prev, NULL);
|
||||
assert(r >= 0);
|
||||
pa_assert_se(sigaction(SIGXCPU, &sigaction_prev, NULL) >= 0);
|
||||
installed = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <ltdl.h>
|
||||
|
||||
|
|
@ -36,19 +35,23 @@
|
|||
|
||||
#include <pulsecore/modinfo.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#include "dumpmodules.h"
|
||||
|
||||
#define PREFIX "module-"
|
||||
|
||||
static void short_info(const char *name, PA_GCC_UNUSED const char *path, pa_modinfo *i) {
|
||||
assert(name && i);
|
||||
pa_assert(name);
|
||||
pa_assert(i);
|
||||
|
||||
printf("%-40s%s\n", name, i->description ? i->description : "n/a");
|
||||
}
|
||||
|
||||
static void long_info(const char *name, const char *path, pa_modinfo *i) {
|
||||
static int nl = 0;
|
||||
assert(name && i);
|
||||
pa_assert(name);
|
||||
pa_assert(i);
|
||||
|
||||
if (nl)
|
||||
printf("\n");
|
||||
|
|
@ -77,6 +80,8 @@ static void long_info(const char *name, const char *path, pa_modinfo *i) {
|
|||
static void show_info(const char *name, const char *path, void (*info)(const char *name, const char *path, pa_modinfo*i)) {
|
||||
pa_modinfo *i;
|
||||
|
||||
pa_assert(name);
|
||||
|
||||
if ((i = pa_modinfo_get_by_name(path ? path : name))) {
|
||||
info(name, path, i);
|
||||
pa_modinfo_free(i);
|
||||
|
|
@ -122,6 +127,8 @@ static int callback(const char *path, lt_ptr data) {
|
|||
}
|
||||
|
||||
void pa_dump_modules(pa_daemon_conf *c, int argc, char * const argv[]) {
|
||||
pa_assert(c);
|
||||
|
||||
if (argc > 0) {
|
||||
int i;
|
||||
for (i = 0; i < argc; i++)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include <ltdl.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
|
|
@ -287,7 +286,7 @@ static int create_runtime_dir(void) {
|
|||
|
||||
static void set_one_rlimit(const pa_rlimit *r, int resource, const char *name) {
|
||||
struct rlimit rl;
|
||||
assert(r);
|
||||
pa_assert(r);
|
||||
|
||||
if (!r->is_set)
|
||||
return;
|
||||
|
|
@ -498,7 +497,7 @@ int main(int argc, char *argv[]) {
|
|||
goto finish;
|
||||
|
||||
default:
|
||||
assert(conf->cmd == PA_CMD_DAEMON);
|
||||
pa_assert(conf->cmd == PA_CMD_DAEMON);
|
||||
}
|
||||
|
||||
if (real_root && !conf->system_instance) {
|
||||
|
|
@ -630,8 +629,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
pa_rtsig_configure(SIGRTMIN+10, SIGRTMAX);
|
||||
|
||||
mainloop = pa_mainloop_new();
|
||||
assert(mainloop);
|
||||
pa_assert_se(mainloop = pa_mainloop_new());
|
||||
|
||||
if (!(c = pa_core_new(pa_mainloop_get_api(mainloop), !conf->disable_shm))) {
|
||||
pa_log("pa_core_new() failed.");
|
||||
|
|
@ -664,9 +662,7 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
|
||||
#ifdef OS_IS_WIN32
|
||||
timer = pa_mainloop_get_api(mainloop)->time_new(
|
||||
pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL);
|
||||
assert(timer);
|
||||
pa_assert_se(timer = pa_mainloop_get_api(mainloop)->time_new(pa_mainloop_get_api(mainloop), pa_gettimeofday(&tv), message_cb, NULL));
|
||||
#endif
|
||||
|
||||
if (conf->daemonize)
|
||||
|
|
@ -674,10 +670,8 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
oil_init();
|
||||
|
||||
if (!conf->no_cpu_limit) {
|
||||
r = pa_cpu_limit_init(pa_mainloop_get_api(mainloop));
|
||||
assert(r == 0);
|
||||
}
|
||||
if (!conf->no_cpu_limit)
|
||||
pa_assert_se(pa_cpu_limit_init(pa_mainloop_get_api(mainloop)) == 0);
|
||||
|
||||
buf = pa_strbuf_new();
|
||||
if (conf->default_script_file)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue