- 1
Class HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Class HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor
https://javadoc.io/doc/org.aspectj/aspectjweaver/1.8.10/org/aspectj/weaver/patterns/HasThisTypePatternTriedToSneakInSomeGene ricOrParameterizedTypePatternMatchingStu ffAnywhereVisitor.html
−1
enum class NodeFlags : int {
None = 0,
Let = 1 << 0,
// ...
}
contextFlags &= ~flag;
// error C2675: unary '~': 'NodeFlags' does not define this operator or a conversion to a type acceptable to the predefined operator
Кому нужны такие гавно-компиляторы? которые даже не в состоянии привети четко прописанные типы?
0
metrics_key::metrics_key(std::initializer_list<std::string> const& il) {
TRI_ASSERT(il.size() > 0);
TRI_ASSERT(il.size() < 3);
name = *il.begin();
if (il.size() == 2) {
labels = *(il.begin()+1);
}
_hash = std::hash<std::string>{}(name + labels);
}
просто гавно
0
if (LD3_state == 0 || LD2_state == 0 || LD1_state == 0)
{
GPIO_SetBits(GPIOB, LED1); //RED ON
LD_Status = NO_LOCK;
}
else
{
LD_Status = LOCK_OK;
}
if (LD4_state == 0 && LD_Status == LOCK_OK)
{
GPIO_SetBits(GPIOB, LED1); //RED ON
}
else
{
GPIO_ResetBits(GPIOB, LED1); //RED OF
}
if (LD4_state == 0 && LD_Status == LOCK_OK)
{
GPIO_ResetBits(GPIOB, LED1); //RED OFF
}
/* Ну можно же было сделать по-человечески, а? */
/* Эквивалентный код: */
LD_Status = LD1_state && LD2_state && LD3_state && LD4_state;
if (LD_Status)
{
GPIO_ResetBits(GPIOB, LED1); //RED OFF
}
else
{
GPIO_SetBits(GPIOB, LED1); //RED ON
}
Как же я ненавижу чье-то легаси...
0
// почему это гавно не будет работать?
auto size = buffer.size() - 1;
auto *ptr = new byte[size];
for (auto i = size; i >= 0; i--)
{
ptr[i] = 0;
}
// a это гавно будет работать :)
auto size = buffer.size() - 1;
auto *ptr = new byte[size];
for (int i = size; i >= 0; i--)
{
ptr[i] = 0;
}
почему это говно не будет работать?
0
// These are equivalent:
fn`some string here`;
fn(['some string here']);
Джаваскриптеры переизобрели руби (ладно-ладно, скрестили с FormattableString из шарпа)
https://styled-components.com/docs/advanced#tagged-template-literals
0
// Since styled-components allows you to use arbitrary input as interpolations, you must be careful to sanitize that input.
// Using user input as styles can lead to any CSS being evaluated in the user's browser that an attacker can place in your application.
// This example shows how bad user input can even lead to API endpoints being called on a user's behalf.
// Oh no! The user has given us a bad URL!
const userInput = '/api/withdraw-funds'
const ArbitraryComponent = styled.div`
background: url(${userInput});
/* More styles here... */
`
в процессе многолетнего пересоздания ruby on rails с нуля фронтендеры умудрились accidentally a bottle of injections
https://styled-components.com/docs/advanced#security
0
type
.....
TSyncParamsPasser = class
PassedJSON:String;
constructor Create(RJS:String);
procedure ProcessExternalCmd;
end;
.....
.....
procedure TForm1.TCPServerExecute(AContext: TIdContext);
begin
.....
SyncParamsPasser:=TSyncParamsPasser.Create(CustomData);
TIdSync.SynchronizeMethod(SyncParamsPasser.ProcessExternalCmd);
FreeAndNil(SyncParamsPasser);
.....
end;
.....
constructor TSyncParamsPasser.Create(RJS:String);
begin
PassedJSON:=RJS;
end;
procedure TSyncParamsPasser.ProcessExternalCmd;
var
JSON:TJSONObject;
begin
JSON:=TJSONObject.ParseJSONValue(PassedJSON) as TJSONObject;
.....
Событие OnExecute компонента TCPServer вызывается из рабочего потока, в котором обрабатывается входящее подключение.
Способ передачи параметров в процедуру, выполняющуюся внутри Synchronize, с помощью класса.
Говно или сойдёт?
0
using System;
namespace NoName
{
class TwoVariables
{
static void Main(string[] args)
{
Int32 FirstVariable = Convert.ToInt32(Console.ReadLine());
Int32 SecondVariable = Convert.ToInt32(Console.ReadLine());
FirstVariable = FirstVariable + SecondVariable;
SecondVariable = FirstVariable - SecondVariable;
FirstVariable = FirstVariable - SecondVariable;
Console.WriteLine("First Variable is: " + FirstVariable);
Console.WriteLine("Second Variable is: " + SecondVariable);
Console.ReadKey();
}
}
}
// Продам гараж
+1
// https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Common-Function-Attributes.html
access
access (access-mode, ref-index)
access (access-mode, ref-index, size-index)
// примеры:
__attribute__ ((access (read_only, 1))) int puts (const char*);
__attribute__ ((access (read_only, 1, 2))) void* memcpy (void*, const void*, size_t);
__attribute__ ((access (read_write, 1), access (read_only, 2))) char* strcat (char*, const char*);
__attribute__ ((access (write_only, 1), access (read_only, 2))) char* strcpy (char*, const char*);
__attribute__ ((access (write_only, 1, 2), access (read_write, 3))) int fgets (char*, int, FILE*);
В GCC 10 какой-то новый атрибут access появился, чтоб более строго что-то там гарантировать:
The access attribute enables the detection of invalid or unsafe accesses by functions to which they apply or their callers, as well as write-only accesses to objects that are never read from. Such accesses may be diagnosed by warnings such as -Wstringop-overflow, -Wuninitialized, -Wunused, and others.
The access attribute specifies that a function to whose by-reference arguments the attribute applies accesses the referenced object according to access-mode. The access-mode argument is required and must be one of three names: read_only, read_write, or write_only. The remaining two are positional arguments.
The required ref-index positional argument denotes a function argument of pointer (or in C++, reference) type that is subject to the access. The same pointer argument can be referenced by at most one distinct access attribute.
The optional size-index positional argument denotes a function argument of integer type that specifies the maximum size of the access. The size is the number of elements of the type referenced by ref-index, or the number of bytes when the pointer type is void*. When no size-index argument is specified, the pointer argument must be either null or point to a space that is suitably aligned and large for at least one object of the referenced type (this implies that a past-the-end pointer is not a valid argument). The actual size of the access may be less but it must not be more.