diff options
author | sjg <sjg@FreeBSD.org> | 2013-04-12 20:48:55 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2013-04-12 20:48:55 +0000 |
commit | 97d8b9495668afa398ab17c8c5f7e223b5fd2e89 (patch) | |
tree | 54038c9ac32a45f8741dcc23fb9a8ffc0e15ff89 /sbin/devd | |
parent | 5ee3bfdb338e7c80af29a67f4425c4be24c7b866 (diff) | |
parent | 086d73aef6d0ab7d21daa2076fdc8d25961f9b05 (diff) | |
download | FreeBSD-src-97d8b9495668afa398ab17c8c5f7e223b5fd2e89.zip FreeBSD-src-97d8b9495668afa398ab17c8c5f7e223b5fd2e89.tar.gz |
sync from head
Diffstat (limited to 'sbin/devd')
-rw-r--r-- | sbin/devd/devd.cc | 33 | ||||
-rw-r--r-- | sbin/devd/devd.conf.5 | 9 | ||||
-rw-r--r-- | sbin/devd/devd.hh | 7 |
3 files changed, 23 insertions, 26 deletions
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index 46f3623..9448775 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -116,7 +116,7 @@ static struct pidfh *pfh; int Dflag; int dflag; int nflag; -int romeo_must_die = 0; +static volatile sig_atomic_t romeo_must_die = 0; static const char *configfile = CF; @@ -319,7 +319,7 @@ media::do_match(config &c) // the name of interest, first try device-name and fall back // to subsystem if none exists. value = c.get_variable("device-name"); - if (value.length() == 0) + if (value.empty()) value = c.get_variable("subsystem"); if (Dflag) fprintf(stderr, "Testing media type of %s against 0x%x\n", @@ -460,7 +460,7 @@ config::open_pidfile() { pid_t otherpid; - if (_pidfile == "") + if (_pidfile.empty()) return; pfh = pidfile_open(_pidfile.c_str(), 0600, &otherpid); if (pfh == NULL) { @@ -528,7 +528,7 @@ config::add_notify(int prio, event_proc *p) void config::set_pidfile(const char *fn) { - _pidfile = string(fn); + _pidfile = fn; } void @@ -585,7 +585,7 @@ config::expand_one(const char *&src, string &dst) src++; // $$ -> $ if (*src == '$') { - dst.append(src++, 1); + dst += *src++; return; } @@ -593,7 +593,7 @@ config::expand_one(const char *&src, string &dst) // Not sure if I want to support this or not, so for now we just pass // it through. if (*src == '(') { - dst.append("$"); + dst += '$'; count = 1; /* If the string ends before ) is matched , return. */ while (count > 0 && *src) { @@ -601,23 +601,23 @@ config::expand_one(const char *&src, string &dst) count--; else if (*src == '(') count++; - dst.append(src++, 1); + dst += *src++; } return; } - // ${^A-Za-z] -> $\1 + // $[^A-Za-z] -> $\1 if (!isalpha(*src)) { - dst.append("$"); - dst.append(src++, 1); + dst += '$'; + dst += *src++; return; } // $var -> replace with value do { - buffer.append(src++, 1); + buffer += *src++; } while (is_id_char(*src)); - dst.append(get_variable(buffer.c_str())); + dst.append(get_variable(buffer)); } const string @@ -653,7 +653,7 @@ config::expand_string(const char *src, const char *prepend, const char *append) } bool -config::chop_var(char *&buffer, char *&lhs, char *&rhs) +config::chop_var(char *&buffer, char *&lhs, char *&rhs) const { char *walker; @@ -912,9 +912,7 @@ event_loop(void) server_fd = create_socket(PIPE); accepting = 1; max_fd = max(fd, server_fd) + 1; - while (1) { - if (romeo_must_die) - break; + while (!romeo_must_die) { if (!once && !dflag && !nflag) { // Check to see if we have any events pending. tv.tv_sec = 0; @@ -1076,8 +1074,7 @@ set_variable(const char *var, const char *val) static void gensighand(int) { - romeo_must_die++; - _exit(0); + romeo_must_die = 1; } static void diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5 index 4c1893d..311228e 100644 --- a/sbin/devd/devd.conf.5 +++ b/sbin/devd/devd.conf.5 @@ -41,7 +41,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd December 16, 2011 +.Dd February 22, 2013 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -181,9 +181,8 @@ Valid media types are: .Dq Li Tokenring , .Dq Li FDDI , .Dq Li 802.11 , -.Dq Li ATM , and -.Dq Li CARP . +.Dq Li ATM . .It Ic subdevice Qq Ar string ; This is shorthand for .Dq Ic match Qo Li subdevice Qc Qq Ar string . @@ -350,6 +349,7 @@ The network interface is attached to the system. The network interface is detached from the system. .El .El +.Pp .It Li DEVFS Events related to the .Xr devfs 5 @@ -369,6 +369,7 @@ The node is destroyed. .El .El +.Pp .It Li USB Events related to the USB subsystem. .Bl -tag -width ".Sy Subsystem" -compact @@ -390,6 +391,7 @@ USB interface is attached to a device. USB interface is detached from a device. .El .El +.Pp .It Li coretemp Events related to the .Xr coretemp 4 @@ -404,6 +406,7 @@ Notification that the CPU core has reached critical temperature. String containing the temperature of the core that has become too hot. .El .El +.Pp .It Li kern Events related to the kernel. .Bl -tag -width ".Sy Subsystem" -compact diff --git a/sbin/devd/devd.hh b/sbin/devd/devd.hh index a48d07b..c8a7610 100644 --- a/sbin/devd/devd.hh +++ b/sbin/devd/devd.hh @@ -41,8 +41,6 @@ class config; class var_list { public: - var_list() {} - virtual ~var_list() {} /** Set a variable in this var list. */ void set_variable(const std::string &var, const std::string &val); @@ -68,7 +66,6 @@ private: struct eps { public: - eps() {} virtual ~eps() {} /** Does this eps match the current config? */ @@ -144,7 +141,7 @@ private: class config { public: - config() : _pidfile("") { push_var_table(); } + config() { push_var_table(); } virtual ~config() { reset(); } void add_attach(int, event_proc *); void add_detach(int, event_proc *); @@ -172,7 +169,7 @@ protected: void parse_files_in_dir(const char *dirname); void expand_one(const char *&src, std::string &dst); bool is_id_char(char) const; - bool chop_var(char *&buffer, char *&lhs, char *&rhs); + bool chop_var(char *&buffer, char *&lhs, char *&rhs) const; private: std::vector<std::string> _dir_list; std::string _pidfile; |