mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
save a bit of code with *strchrnul = '\0' trick
function old new delta nextline 59 55 -4 include_conf 902 898 -4 read_config 414 406 -8 fsck_main 1880 1869 -11
This commit is contained in:
parent
abee3d0e0d
commit
c03e872112
@ -349,9 +349,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs)
|
|||||||
|
|
||||||
*ret_fs = 0;
|
*ret_fs = 0;
|
||||||
strip_line(line);
|
strip_line(line);
|
||||||
cp = strchr(line, '#');
|
*strchrnul(line, '#') = '\0'; /* Ignore everything after comment */
|
||||||
if (cp)
|
|
||||||
*cp = '\0'; /* Ignore everything after the comment char */
|
|
||||||
cp = line;
|
cp = line;
|
||||||
|
|
||||||
device = parse_word(&cp);
|
device = parse_word(&cp);
|
||||||
|
@ -242,11 +242,8 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf
|
|||||||
|
|
||||||
while (reads(fd, buffer, buflen)) {
|
while (reads(fd, buffer, buflen)) {
|
||||||
int l;
|
int l;
|
||||||
char *p;
|
|
||||||
|
|
||||||
p = strchr(buffer, '#');
|
*strchrnul(buffer, '#') = '\0';
|
||||||
if (p)
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
l = strlen(buffer);
|
l = strlen(buffer);
|
||||||
|
|
||||||
|
@ -554,13 +554,9 @@ static void setup(servtab_t *sep)
|
|||||||
|
|
||||||
static char *nextline(void)
|
static char *nextline(void)
|
||||||
{
|
{
|
||||||
char *cp;
|
|
||||||
|
|
||||||
if (fgets(line, LINE_SIZE, fconfig) == NULL)
|
if (fgets(line, LINE_SIZE, fconfig) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
cp = strchr(line, '\n');
|
*strchrnul(line, '\n') = '\0';
|
||||||
if (cp)
|
|
||||||
*cp = '\0';
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,14 +332,12 @@ int read_config(const char *file)
|
|||||||
|
|
||||||
while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) {
|
while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) {
|
||||||
char debug_orig[READ_CONFIG_BUF_SIZE];
|
char debug_orig[READ_CONFIG_BUF_SIZE];
|
||||||
char *p;
|
|
||||||
|
|
||||||
lm++;
|
lm++;
|
||||||
p = strchr(buffer, '\n');
|
*strchrnul(buffer, '\n') = '\0';
|
||||||
if (p) *p = '\0';
|
if (ENABLE_FEATURE_UDHCP_DEBUG)
|
||||||
if (ENABLE_FEATURE_UDHCP_DEBUG) strcpy(debug_orig, buffer);
|
strcpy(debug_orig, buffer);
|
||||||
p = strchr(buffer, '#');
|
*strchrnul(buffer, '#') = '\0';
|
||||||
if (p) *p = '\0';
|
|
||||||
|
|
||||||
token = strtok(buffer, " \t");
|
token = strtok(buffer, " \t");
|
||||||
if (!token) continue;
|
if (!token) continue;
|
||||||
|
@ -1448,7 +1448,7 @@ static int singlemount(struct mntent *mp, int ignore_busy)
|
|||||||
// Might this be a virtual filesystem?
|
// Might this be a virtual filesystem?
|
||||||
|
|
||||||
if (ENABLE_FEATURE_MOUNT_HELPERS
|
if (ENABLE_FEATURE_MOUNT_HELPERS
|
||||||
&& (strchr(mp->mnt_fsname,'#'))
|
&& (strchr(mp->mnt_fsname, '#'))
|
||||||
) {
|
) {
|
||||||
char *s, *p, *args[35];
|
char *s, *p, *args[35];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user