由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 老码农骂小码农的强文。 (转载)
相关主题
大家新年好。 请教一个 c interview question (转载)BBC 编程风格面试题,求指教
中国人面试果然很好人三哥题刷的不赖啊
砸了面试,发面题问个越界的问题
Apple的一些C++概念题请教一道Leetcode 题, 多谢
C++ Q: sizeof请教leetcode一道题
求问下面这几行代码是做什么的,非常感谢!问一个Airbnb的design google reader
onsite完,攒rp系列(二)[合集] 那个Google random generate 1-7的题怎么做啊?
bfs vs dfs我的bloomberg肯定没戏了,发点面试题攒人品吧
相关话题的讨论汇总
话题: code话题: hlen话题: mtu话题: frag话题: idiotic
进入JobHunting版参与讨论
1 (共1页)
t*****d
发帖数: 525
1
【 以下文字转载自 PDA 讨论区 】
发信人: weidong (伊拉克学习小组副组长), 信区: PDA
标 题: 老码农骂小码农的强文。
发信站: BBS 未名空间站 (Mon Nov 2 19:52:49 2015, 美东)
Linus Tovalds骂瞎写代码的小码农,荡气回肠,应该下发所有码农学习。
Christ people. This is just sh*t
.The conflict I get is due to stupid new gcc header file crap. But what
makes me upset is that the crap is for completely bogus reasons.
This is the old code in net/ipv6/ip6_output.c:
mtu -= hlen + sizeof(struct frag_hdr);
and this is the new “improved” code that uses fancy stuff that wants
magical built-in compiler support and has silly wrapper functions for when
it doesn’t exist:
if (overflow_usub(mtu, hlen + sizeof(struct frag_hdr), &mtu) ||
mtu <= 7)
goto fail_toobig;
and anybody who thinks that the above is (a) legible (b) efficient (even
with the magical compiler support) (c) particularly safe is just incompetent
and out to lunch.
The above code is sh*t, and it generates shit code. It looks bad, and there
’s no reason for it.
The code could *easily* have been done with just a single and understandable
conditional, and the compiler would actually have generated better code,
and the code would look better and moreunderstandable. Why is this not
if (mtu < hlen + sizeof(struct frag_hdr) + 8)
goto fail_toobig;
mtu -= hlen + sizeof(struct frag_hdr);
which is the same number of lines, doesn’t use crazy helper functions that
nobody knows what they do, and is much more obvious what it actually does. I
guarantee that the second more obvious version is easier to read and
understand. Does anybody really want to dispute this?
Really. Give me *one* reason why it was written in that idiotic way with two
different conditionals, and a shiny new nonstandard function that wants
particular compiler support to generate even half-way sane code, and even
then generates worse code? A shiny function that we have never ever needed
anywhere else, and that is just compiler-masturbation.
And yes, you still could have overflow issues if the whole “hlen +xyz”
expression overflows, but quite frankly, the “overflow_usub()“ code had
that too. So if you worry about that, then you damn well didn’t do the
right thing to begin with.
So I really see no reason for this kind of complete idiotic crap.
Tell me why. Because I’m not pulling this kind of completely insane stuff
that generates conflicts at rc7 time, and that seems to have absolutely no
reason for being an idiotic unreadable mess.
The code seems *designed* to use that new “overflow_usub()“ code. It seems
to be an excuse to use that function.
And it’s a f*cking bad excuse for that braindamage.
I’m sorry, but we don’t add idiotic new interfaces like this for idiotic
new code like that.
Yes, yes, if this had stayed inside the network layer I would never have
noticed. But since I *did* notice, I really don’t want to pull this. In
fact, I want to make it clear to *everybody* that code like this is
completely unacceptable. Anybody who thinks that code like this is “safe”
and “secure” because it uses fancy overflow detection functions is so far
out to lunch that it’s not even funny. All this kind of crap does is to
make the code an unreadable mess with code that no sane person will ever
really understand what it actually does.
Get rid of it. And I don’t *ever* want to see that shit again.
Linus
★ 发自iPhone App: ChineseWeb 1.0.4
q********i
发帖数: 152
2
大神脾气还是那么爆啊
f******n
发帖数: 198
3
He certainly has a point, but he's not completely correct. If hlen + sizeof(
struct frag_hdr) does not overflow, but hlen + sizeof(struct frag_hdr) + 8
does, his version will give a negative mtu result.

【在 t*****d 的大作中提到】
: 【 以下文字转载自 PDA 讨论区 】
: 发信人: weidong (伊拉克学习小组副组长), 信区: PDA
: 标 题: 老码农骂小码农的强文。
: 发信站: BBS 未名空间站 (Mon Nov 2 19:52:49 2015, 美东)
: Linus Tovalds骂瞎写代码的小码农,荡气回肠,应该下发所有码农学习。
: Christ people. This is just sh*t
: .The conflict I get is due to stupid new gcc header file crap. But what
: makes me upset is that the crap is for completely bogus reasons.
: This is the old code in net/ipv6/ip6_output.c:
: mtu -= hlen + sizeof(struct frag_hdr);

c****p
发帖数: 6474
4
以前有一次有人为了fix一个bug把一个数改成了另一个,
Linus问为什么这么改,那人说因为改成这个数就没bug了。
Linus就怒了,弄不明白为什么之前不要TMD随便瞎JB改。

【在 t*****d 的大作中提到】
: 【 以下文字转载自 PDA 讨论区 】
: 发信人: weidong (伊拉克学习小组副组长), 信区: PDA
: 标 题: 老码农骂小码农的强文。
: 发信站: BBS 未名空间站 (Mon Nov 2 19:52:49 2015, 美东)
: Linus Tovalds骂瞎写代码的小码农,荡气回肠,应该下发所有码农学习。
: Christ people. This is just sh*t
: .The conflict I get is due to stupid new gcc header file crap. But what
: makes me upset is that the crap is for completely bogus reasons.
: This is the old code in net/ipv6/ip6_output.c:
: mtu -= hlen + sizeof(struct frag_hdr);

a**********t
发帖数: 631
5
如果不考虑上下文,你是对的。
但我认为Linux的改动是基于原来code的上下文,这里hlen是IPV6的header length, 实
际上只是一个非常小的uint16 value cast到int又到uint(从ip6_find_1stfragopt()返
回),这样看来原来的写法就非常画蛇添足了。
我对linux的一大complaint就是type cast 太随心所欲,整一个乱七八糟。

sizeof(

【在 f******n 的大作中提到】
: He certainly has a point, but he's not completely correct. If hlen + sizeof(
: struct frag_hdr) does not overflow, but hlen + sizeof(struct frag_hdr) + 8
: does, his version will give a negative mtu result.

s*****m
发帖数: 8094
6
难怪啊,这是够傻逼的。
话说回来了,这种傻逼世界上还真的很多。

【在 q********i 的大作中提到】
: 大神脾气还是那么爆啊
1 (共1页)
进入JobHunting版参与讨论
相关主题
我的bloomberg肯定没戏了,发点面试题攒人品吧C++ Q: sizeof
给大家看几道C 小程序求问下面这几行代码是做什么的,非常感谢!
算法题目一问onsite完,攒rp系列(二)
讨论个idea题bfs vs dfs
大家新年好。 请教一个 c interview question (转载)BBC 编程风格面试题,求指教
中国人面试果然很好人三哥题刷的不赖啊
砸了面试,发面题问个越界的问题
Apple的一些C++概念题请教一道Leetcode 题, 多谢
相关话题的讨论汇总
话题: code话题: hlen话题: mtu话题: frag话题: idiotic