mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul P Komkoff Jr <i@stingr.net>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Some useless cleanup
Date: Thu, 9 May 2002 15:33:46 +0400	[thread overview]
Message-ID: <20020509113346.GB1125@stingr.net> (raw)
In-Reply-To: <20020509102841.GA1125@stingr.net> <200205091102.g49B2AX25891@Port.imtp.ilyichevsk.odessa.ua>

Replying to Denis Vlasenko:
> Well, it isn't bad, but what's the point in multiple
> set_xxxxxx(char *dst, char *src) functions?
> 
> Maybe it makes more sense to have a generic macro
> which copies string into char[N] buffer, avoiding overflow.
> 

Generic plan. I has something in mind when asked, but not this ...

Actually in task_t.comm we have 2 cases
1. strncpy(a, b, sz)
2. snprintf(a, n, blah-blah...)

I thought somebody will beat me for completely eliminating strcpyn and
replacing it with snprintf in ALL CASES which is more expensive.

> A macro:
> 
> #define STRNCPY(dst,src) \
> 	do { \
> 		/* todo: put clever check that dst is char[] here */ \
> 		strncpy((dst), (src), sizeof(dst)-1); \
> 		dst[sizeof(dst)-1] = '\0'; \
> 	} while(0)

Abstracting .comm access can result in, finally, replacing comm[16] with,
for example, *comm

Or if we require to do match_comm (netfilter match, connections belong to
process specified by name) job we can patchhook somewhere in set_xxx to
avoid excessive for_each_tasked strcmps.

... more?

-- 
Paul P 'Stingray' Komkoff 'Greatest' Jr // (icq)23200764 // (irc)Spacebar
  PPKJ1-RIPE // (smtp)i@stingr.net // (http)stingr.net // (pgp)0xA4B4ECA4

      reply	other threads:[~2002-05-09 11:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-09 10:28 Paul P Komkoff Jr
2002-05-09 12:36 ` Rusty Russell
2002-05-09 22:23   ` Erik Andersen
2002-05-10  8:20     ` Bernd Petrovitsch
2002-05-10 11:42     ` Oliver Xymoron
2002-05-12 12:09     ` Rusty Russell
2002-05-10  9:44   ` Paul P Komkoff Jr
2002-05-09 15:09 ` Denis Vlasenko
2002-05-09 11:33   ` Paul P Komkoff Jr [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020509113346.GB1125@stingr.net \
    --to=i@stingr.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®