problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
CPUState *cs)
{
sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
sPAPRCapabilities caps;
caps = smc->default_caps;
return caps;
}
| 1threat
|
Year Part Update in sql DateTime Column : [![Table_Data][1]][1]
[1]: https://i.stack.imgur.com/o2Fxq.png
Need to change only the year part of every ChangedDate Column to 2017.
i.e
**2017**-02-08 13:55:30.193
**2017**-02-08 13:55:30.193
**2017**-02-08 13:55:30.193
| 0debug
|
How do i generate a list of integers from 1 to 200 where it only prints the first 20 odd/even numbers? : <p>How do i generate a list of integers from 1 to 200 where it only prints the first 20 odd/even numbers?</p>
| 0debug
|
Firebase Realtime database Write data issue : Iam working on android with firebase database.I have done all the settings correct and injected value to DB.But i have an issue as listed below
My code :
package app.com.test;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.nio.file.Files;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Button b;
EditText name;
DatabaseReference rootRef,demoRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b= findViewById(R.id.button2);
name= findViewById(R.id.editText);
//age=findViewById(R.id.editText2);
rootRef= FirebaseDatabase.getInstance().getReference();
demoRef=rootRef.child("demo");
b.setOnClickListener(this);
}
@Override
public void onClick(View view) {
String n=name.getText().toString();
//int a = Integer.parseInt(age.getText().toString());
demoRef.push().setValue(n);
//demoRef.push().setValue(a);
Toast.makeText(this, "DB inserted", Toast.LENGTH_LONG).show();
}
}
Error :
W/RepoOperation: setValue at /demo/-L5xSv3ICHg2BFupI7DG failed: DatabaseError: Permission denied
Kindly help me with it
| 0debug
|
static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i)
{
return shared_page->vcpu_iodata[i].vp_eport;
}
| 1threat
|
how can use the fields in the class in python : `
class TPCANTimestamp (Structure):
"""
Represents a timestamp of a received PCAN message
Total Microseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow
"""
_fields_ = [ ("millis", c_uint), # Base-value: milliseconds: 0.. 2^32-1
("millis_overflow", c_ushort), # Roll-arounds of millis
("micros", c_ushort) ]`
How can i use the fileds in the TPCANTimestamp class ??
| 0debug
|
dictionary pythoon with a csv file : i'm new at all this coding but have loots of motivation even when thigs don't work.
i'm trying to work on a dictionary with a CSV file i get to open a new file and edit it but i think i'm missing something when trying to read from the csv file..
here is the code i get errors in rows 39-41 i'm probably doing something wrong but what is it?
import csv
import os
import os.path
phonebook = {}
def print_menu():
print('1. Print phone book')
print('2. add phone book')
print('3. look for number using first name only')
print('4. look by last name')
print('5. exit')
print()
menu_selection = 0
while menu_selection != 5:
if os.path.isfile('my_phonebook.csv') == True:
csv_file = open('my_phonebook.csv', 'a', newline = '')
writer = csv.writer(csv_file)
else:
csv_file = open('my_phonebook.csv', 'w', newline = '')
writer = csv.writer(csv_file)
headers = ['first_name','last_name','phone_number']
writer.writerow(headers)
print_menu()
menu_selection = int(input('type menu selection number'))
if menu_selection == 2: #add list in phone book
first_name = input("enter first name: ")
last_name = input("enter last name: ")
phone_number = input("enter phone number: ")
writer.writerow([first_name,last_name,phone_number])
csv_file.close()
elif menu_selection == 1: #print phone book
print("phone book:")
listGen = csv.reader(csv_file, delimiter=' ', quotechar='|') #error starts here and in the next two rows...
for row in csv_file:
print(row)
elif menu_selection == 3: #look for number using first name only
print('look up number')
first_name = input('first name:')
if first_name in phonebook:
print('the number is', phonebook[phone_number])
else:
print('name not found')
elif menu_selection == 4: #print all details of last name entered
print('search by last name')
last_name = input('please enter last name: ')
for row in csv_file:
print(row)
| 0debug
|
what does the ! mean in Angular? i.e $scope.selected = !$scope.selected; : <p>I was wondering what does the ! actually mean in this method</p>
<pre><code> $scope.toggleSelected = function () {
$scope.selected = !$scope.selected;
};
</code></pre>
<p>I understand it's allowing me to set a selected item and it won't work without it but what exactly is the ! for?</p>
| 0debug
|
Is there a way to know what pattern was used? : <p>Is there a way to know which pattern was used in this case. I mean sometime i can get input like "123<=456" sometime like "123>=456". My question is, is it posible to know if "<=" was the used pattern or ">=" </p>
<pre><code>Pattern pattern = Pattern.compile("(<=)|(>=)");
String x= "123<=456"; \\"123>=456"
String[] t = pattern.split(x);
</code></pre>
| 0debug
|
Can we create sql DB server backup on different database(free database)? : <p>I have SQL database with huge amount of data. I want to create backup DB server using free databsase (e.g.Mysql) which will be back up server of SQL database. How can I do this ?</p>
| 0debug
|
python file lookup (database?) : <p><strong>Not asking to be spoonfed, more in what 'direction' I should be looking in order to learn this.</strong></p>
<p>So I have this file/database and I want users to type a name from the "Name" section. then the files searches for that name and gives the email/IP as output.</p>
<p>The format is:
NAME:UUID:EMAIL:IP</p>
<p>I want the name which the user asked to search only get 'searched' from the "NAME" part. and the output has to be "EMAIL" or "IP"</p>
<p>Could someone help me out and point me in a direction where to make this? I've tried searching but I can't seem to find anything.</p>
| 0debug
|
Twig: Include external Code from an SVG file : <p>Is it possible to inlcude code from a svg file directly into a twig template file?</p>
<p>Something like:</p>
<pre><code>{% include 'my.svg' %}
</code></pre>
<p>that will result in:</p>
<pre><code><svg viewbox=".... />
</code></pre>
| 0debug
|
Shell script wait the end of a nohup command and show the logs on the screen : I would like to execute a nohup commande un shell script, and while running, I would like to see its logs on the screen.
Secondly, I Also want to wait the end of the execution of this one, to start the execution of the next command.
please if someone could help me?
| 0debug
|
void vnc_display_init(DisplayState *ds)
{
VncDisplay *vs = g_malloc0(sizeof(*vs));
dcl = g_malloc0(sizeof(DisplayChangeListener));
ds->opaque = vs;
dcl->idle = 1;
vnc_display = vs;
vs->lsock = -1;
#ifdef CONFIG_VNC_WS
vs->lwebsock = -1;
#endif
vs->ds = ds;
QTAILQ_INIT(&vs->clients);
vs->expires = TIME_MAX;
if (keyboard_layout)
vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
else
vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
if (!vs->kbd_layout)
exit(1);
qemu_mutex_init(&vs->mutex);
vnc_start_worker_thread();
dcl->ops = &dcl_ops;
register_displaychangelistener(ds, dcl);
}
| 1threat
|
Python-Regex remove quotes in the 'keys' section of a string in a string of key/value pairs : I am trying to remove single quotes from the 'key' pairs in a string, but leave the single quotes in the value pair.
Each time the key/value options will be different so it needs to be generic. The only thing that will stay is the commas.
For example my original string is:
````
'Key'='Value', 'Key'='Value', 'Key'='Value', 'Key'='Value'
````
and my desired outcome is:
````
Key='Value', Key='Value', Key='Value', Key='Value'
````
Not sure how I would go about doing this in regex/python. I've tried looping through regex matches and re.sub but to no avail
Any help would be wonderful, thanks
| 0debug
|
Find all words starting with $ : I have a requirement to replace all words starting with $ in a Word document
sample:
$Address
$Lastname etc.
Now at the beginning I must create a list with all words that start with $
After that I replace all words
$Lastname -> Waning etc
How can I create a list with all words starting with $ in spiredoc ?
| 0debug
|
plot several image files in matplotlib subplots : <p>I would like to create a matrix subplot and display each BMP files, from a directory, in a different subplot, but I cannot find the appropriate solution for my problem, could somebody helping me?.</p>
<p>This the code that I have:</p>
<pre><code>import os, sys
from PIL import Image
import matplotlib.pyplot as plt
from glob import glob
bmps = glob('*trace*.bmp')
fig, axes = plt.subplots(3, 3)
for arch in bmps:
i = Image.open(arch)
iar = np.array(i)
for i in range(3):
for j in range(3):
axes[i, j].plot(iar)
plt.subplots_adjust(wspace=0, hspace=0)
plt.show()
</code></pre>
<p>I am having the following error after executing:</p>
<p><a href="https://i.stack.imgur.com/7ysnN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7ysnN.png" alt="enter image description here"></a></p>
| 0debug
|
void spapr_drc_detach(sPAPRDRConnector *drc)
{
trace_spapr_drc_detach(spapr_drc_index(drc));
drc->unplug_requested = true;
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
trace_spapr_drc_awaiting_isolated(spapr_drc_index(drc));
return;
}
if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI &&
drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
trace_spapr_drc_awaiting_unusable(spapr_drc_index(drc));
return;
}
spapr_drc_release(drc);
}
| 1threat
|
Error:Failed to resolve: android.arch.core:common:1.1.0 : <p>My system suddenly went off and I switched it on and I got Error:Failed to resolve: android.arch.core:common:1.1.0 error in my android studio. I have tried clean and rebuild project but it did not work. I have researched on the internet but none could solve my problem.</p>
<p>build. gradle(project)</p>
<pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
</code></pre>
<p>build.gradle(App)</p>
<pre><code>apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.example.system2.tranxav"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.stripe:stripe-android:6.1.1'
compile 'com.stripe:stripe-java:1.47.0'
compile 'com.stripe:stripe-android:1.0.4'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.volley:volley:1.0.0' // dependency file for Volley
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.basgeekball:awesome-validation:1.3'
compile 'com.parse:parse-android:1.16.5'
compile 'com.parse.bolts:bolts-tasks:1.4.0'
compile 'com.parse.bolts:bolts-applinks:1.4.0'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}
</code></pre>
<p>I don't know what could be the cause of the problem.</p>
| 0debug
|
document.write('<script src="evil.js"></script>');
| 1threat
|
Issue with cherry pick: changes from previous commits are also applied : <p>In my project, I released a version several months ago. After that release, I have done many changes on the master branch.</p>
<p>If I encounter some bugs which were there in the last release, I fix them on the master branch, then cherry pick them to the branch I have created at the last release. Then I can provide a new release with only the bug fix, without releasing the unfinished work on master branch.</p>
<p>When I tried to cherry pick a certain bug fix to the release branch, I encountered a merge conflict.</p>
<p>As I understand, cherry picking a certain commit introduces a new commit to the target branch, with the changes done in the cherry picked commit.</p>
<p>But, when I tried to fix the merge conflict, it seems that git has applied changes on master branch which are not introduced by the cherry picked commit to my release branch. The cherry picked commit only introduced couple of lines to the conflicted file. But, when I try to resolve the conflicts, I see that several other lines are also introduced to the file, which were added to master branch with different commits.</p>
<p>Can someone explain why changes from commits other than cherry picked commit are introduced to my release branch?</p>
| 0debug
|
Why bootloaders are in assembly? : <p>I have read couple of embedded projects and in all of them the bootloader is written in Assembly instead of C. IS there any reason for this?</p>
| 0debug
|
int ff_h264_frame_start(H264Context *h)
{
Picture *pic;
int i, ret;
const int pixel_shift = h->pixel_shift;
int c[4] = {
1<<(h->sps.bit_depth_luma-1),
1<<(h->sps.bit_depth_chroma-1),
1<<(h->sps.bit_depth_chroma-1),
-1
};
if (!ff_thread_can_start_frame(h->avctx)) {
av_log(h->avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n");
return -1;
}
release_unused_pictures(h, 1);
h->cur_pic_ptr = NULL;
i = find_unused_picture(h);
if (i < 0) {
av_log(h->avctx, AV_LOG_ERROR, "no frame buffer available\n");
return i;
}
pic = &h->DPB[i];
pic->f.reference = h->droppable ? 0 : h->picture_structure;
pic->f.coded_picture_number = h->coded_picture_number++;
pic->field_picture = h->picture_structure != PICT_FRAME;
pic->f.key_frame = 0;
pic->sync = 0;
pic->mmco_reset = 0;
if ((ret = alloc_picture(h, pic)) < 0)
return ret;
if(!h->sync && !h->avctx->hwaccel)
avpriv_color_frame(&pic->f, c);
h->cur_pic_ptr = pic;
h->cur_pic = *h->cur_pic_ptr;
h->cur_pic.f.extended_data = h->cur_pic.f.data;
ff_er_frame_start(&h->er);
assert(h->linesize && h->uvlinesize);
for (i = 0; i < 16; i++) {
h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->linesize * ((scan8[i] - scan8[0]) >> 3);
h->block_offset[48 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->linesize * ((scan8[i] - scan8[0]) >> 3);
}
for (i = 0; i < 16; i++) {
h->block_offset[16 + i] =
h->block_offset[32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3);
h->block_offset[48 + 16 + i] =
h->block_offset[48 + 32 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * h->uvlinesize * ((scan8[i] - scan8[0]) >> 3);
}
for (i = 0; i < h->slice_context_count; i++)
if (h->thread_context[i]) {
ret = alloc_scratch_buffers(h->thread_context[i], h->linesize);
if (ret < 0)
return ret;
}
memset(h->slice_table, -1,
(h->mb_height * h->mb_stride - 1) * sizeof(*h->slice_table));
if (h->avctx->codec_id != AV_CODEC_ID_SVQ3)
h->cur_pic_ptr->f.reference = 0;
h->cur_pic_ptr->field_poc[0] = h->cur_pic_ptr->field_poc[1] = INT_MAX;
h->next_output_pic = NULL;
assert(h->cur_pic_ptr->long_ref == 0);
return 0;
}
| 1threat
|
pointers, sizeof() and address in c++ : [This is the link to the program][1]
[1]: https://github.com/an0nh4x0r/code/blob/master/c_cpp/pointers/2.cpp
The sizeof() function in cpp gives sizeof(int) 4 bytes, in g++ compiler. So i printed the sizeof(1), sizeof(2), sizeof(0) to terminal and i got 4 bytes.
so i tried some pointer arithmetic in the program in above link. I added 1 to a pointer variable. lets say int *p; int a = 10; now i assigned p = &a; now when i printed p it gives 0x24fe04 and when i printed p + 0 its same. But when i tried adding p + 1 and p + 2 it gives different output like this 0x24fe08, 0x24fe0c respectively. Please help me understanding this arithmetic. why p+1, p+2 is not equal as in address it's contributing the same 4 bytes.
| 0debug
|
Do we need to use background thread for retrieving data using firebase? : <p>I've an android app where I'm retrieving data into a Fragment. And I believe that Firebase manages its asynchronous calls. But still I've doubt the if we need to write the Firebase code in the background thread or not?.</p>
<p>If we need to write it into the background thread then can you please tell which operations takes more time. eg:</p>
<pre><code>mDatabase = FirebaseDatabase.getInstance().getReference().child("Blog");
</code></pre>
<p>I think that performing this on the main UI thread may become risk full because setting connection between database may sometime take large time.</p>
| 0debug
|
def len_log(list1):
max=len(list1[0])
for i in list1:
if len(i)>max:
max=len(i)
return max
| 0debug
|
Laravel - Seeding Relationships : <p>In Laravel, database seeding is generally accomplished through Model factories. So you define a blueprint for your Model using Faker data, and say how many instances you need:</p>
<pre><code>$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10),
];
});
$user = factory(App\User::class, 50)->create();
</code></pre>
<p>However, lets say your User model has a <code>hasMany</code> relationship with many other Models, like a <code>Post</code> model for example:</p>
<pre><code>Post:
id
name
body
user_id
</code></pre>
<p>So in this situation, you want to seed your Posts table with <strong><em>actual</em></strong> users that were seeded in your Users table. This doesn't seem to be explicitly discussed, but I did find the following in the Laravel docs:</p>
<pre><code>$users = factory(App\User::class, 3)
->create()
->each(function($u) {
$u->posts()->save(factory(App\Post::class)->make());
});
</code></pre>
<p>So in your User factory, you create X number of Posts for each User you create. However, in a large application where maybe 50 - 75 Models share relationships with the User Model, your User Seeder would essentially end up seeding the entire database with all it's relationships.</p>
<p>My question is: Is this the best way to handle this? The only other thing I can think of is to Seed the Users first (without seeding any relations), and then pull random Users from the DB as needed while you are seeding other Models. However, in cases where they need to be unique, you'd have to keep track of which Users had been used. Also, it seems this would add a lot of extra query-bulk to the seeding process.</p>
| 0debug
|
static void breakpoint_handler(CPUX86State *env)
{
CPUBreakpoint *bp;
if (env->watchpoint_hit) {
if (env->watchpoint_hit->flags & BP_CPU) {
env->watchpoint_hit = NULL;
if (check_hw_breakpoints(env, 0))
raise_exception_env(EXCP01_DB, env);
else
cpu_resume_from_signal(env, NULL);
}
} else {
QTAILQ_FOREACH(bp, &env->breakpoints, entry)
if (bp->pc == env->eip) {
if (bp->flags & BP_CPU) {
check_hw_breakpoints(env, 1);
raise_exception_env(EXCP01_DB, env);
}
break;
}
}
if (prev_debug_excp_handler)
prev_debug_excp_handler(env);
}
| 1threat
|
How to observe touched event on Angular 2 NgForm? : <p>It is possible to subscribe a callback to an <code>NgForm</code>'s <code>valueChanges</code> observable property in order to react to changes in the values of the controls of the form.</p>
<p>I need, in the same fashion, to react to the event of the user <em>touching one of the form controls</em>.</p>
<p><a href="https://github.com/angular/angular/blob/master/modules/%40angular/forms/src/directives/abstract_control_directive.ts" rel="noreferrer">This class</a> seem to define the <code>valueChanges</code> Observable and the <code>touched</code> property is defined as a boolean.</p>
<p><strong>Is there a way to to react to the "control touched" event?</strong> </p>
| 0debug
|
Strange generic function appear in view controller after converting to swift 3 : <p>In my project, after converting to swift 3, a new function appeared before my <code>ViewController</code> class: </p>
<pre><code>fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
switch (lhs, rhs) {
case let (l?, r?):
return l < r
case (nil, _?):
return true
default:
return false
}
}
</code></pre>
<p>What does this function do? Why do I need it? </p>
| 0debug
|
How to clear focus from an inputfield in React Native? : <p>I have an inputfield and I want to get rid of the focus on it, after i click the submit button.</p>
<p>Any suggestions on how I would go about this?</p>
| 0debug
|
receiving array of data using UART arduino : <p>i am trying to send data through UART in arduino to fingerprint scanner
i am using an array to send the commands and it works fine </p>
<pre><code>for(i =0 ; i<= 24 ; i++)
{
Serial.write(SendArray[i]);
SendArray[i] =0;
}
</code></pre>
<p>the problem is when i'm trying to receive response from the fingerprint
the fingerprint response is 24 bytes so i tried to receive the bytes and store them in an array of 24 elements </p>
<pre><code> for(k=0 ; k<=24 ; k++)
{
RecieveArray[k] = Serial.read();
}
</code></pre>
<p>but when i try to print an element from the received array i get strange symbols </p>
| 0debug
|
Why use C# async/await for CPU-bound tasks : <p>I'm getting the hang of the async/await keywords in C#, and how they facilitate asynchronous programming - allowing the the thread to be used elsewhere whilst some I/O bound task like a db call is going on.</p>
<p>I have read numerous times that async/await is for I/O bound tasks, not CPU-bound tasks. CPU-bound tasks should be performed on a separate background thread. Mentioned several times in these <a href="https://channel9.msdn.com/Series/Three-Essential-Tips-for-Async" rel="noreferrer">videos</a>. All ok.</p>
<p>However, when starting long-running CPU-bound work on a new thread using <code>Task.Run</code>, you then have to <code>await</code> it at some point. So aren't we using async/await here for a CPU-bound task too? See example below.</p>
<pre><code>public async Task SomeMethodAsync()
{
int result = await Task.Run(() =>
{
// Do lots of CPU bound calculations...
return result;
}
// Then do something with the result.
}
</code></pre>
| 0debug
|
Sudoku Checker Program C : <p>I'm trying to complete a sudoku solution checker program in c. I'm still trying to understand the steps in building this program before I start coding it. I found this example online <a href="http://practicecprogram.blogspot.com/2014/10/c-program-to-find-out-if-solved-sudoku.html" rel="nofollow">http://practicecprogram.blogspot.com/2014/10/c-program-to-find-out-if-solved-sudoku.html</a></p>
<p>There are a few questions I still don't understand.</p>
<p>1 For my program I am given a text file with the first number being a number that says how many sets of sudoku solutions it contains. I am almost understanding how to check just one solution but having to do it for N solutions and making the program work for multiple sudoku solutions confuses me. Especially in making my 2d arrays for the values. My ouput is supposed to only be Yes or No on a new line for however many N sets.</p>
<p>2 Is checking that all rows and columns have sums of 45 and that the values are >0, <10 enough to prove that the solution is valid? I'm assuming since every puzzle only has one solution I don't have to check each 3x3 grid to make it doesn't contain duplicates if each row and column sum to 45.</p>
| 0debug
|
void test_self_modifying_code(void)
{
int (*func)(void);
func = (void *)code;
printf("self modifying code:\n");
printf("func1 = 0x%x\n", func());
code[1] = 0x2;
printf("func1 = 0x%x\n", func());
}
| 1threat
|
C - Single Linked List: problems with scanf and pointers : <p><em>Ok this is going to be a really bad question, I can't figure out how to assign a float number with scanf:</em> </p>
<pre><code>float get_value(float * ptr){
printf("Immettere valore: ");
scanf("%f", &(*ptr)); //THE ERROR IS HERE
return *ptr; }
</code></pre>
<p><em>Don't really know what to do here. (THE ERROR IS HERE in the code)
Here is the other interested part:</em> </p>
<pre><code>... switch (ch) {
case 1: *value = get_value(value);
break;
case 2: pre_insert(&listA, value);
break;
case 3: pre_insert(&listB, value);
break;
case 4: end_insert(&listA, value);
break;
case 5: end_insert(&listB, value);
break;
default: printf("\nComando non valido.\n");
break;
}
}...
</code></pre>
<p><em>function prototipe:</em> <code>float get_value(float*);</code></p>
| 0debug
|
why is $header undefined here? : <p>i am trying to send mail using php. i have removed the comment from the SMTP port and mail but Apache throws undefined variable $header in line no.5. what is wrong here? </p>
<pre><code><?php include "head.php";?>
<?php
$from= "smechailes@gmail.com";
$Headers = "";
$header .= "MIME-Version: 1.0 \r\n";
$header .= "Content-type: text/html; Charset= iso-859-1 \r\n";
$header .= "From: ".$from." \r\n";
$to = "setok321@gmail.com";
$subject = "test-mail";
$message ="<h1>hello</h1>";
$mail = mail($to, $subject, $message, $header);
echo (int)$mail;
?>
<?php include "foot.php";?>
</code></pre>
| 0debug
|
How do I print an integer in binary with leading zeros? : <p>I'm doing some bit twiddling and I'd like to print all the bits in my u16.</p>
<pre><code>let flags = 0b0000000000101100u16;
println!("flags: {:#b}", flags);
</code></pre>
<p>This prints <code>flags: 0b101100</code>.</p>
<p>How do I make it print <code>flags: 0b0000000000101100</code>?</p>
| 0debug
|
static void mirror_start_job(const char *job_id, BlockDriverState *bs,
int creation_flags, BlockDriverState *target,
const char *replaces, int64_t speed,
uint32_t granularity, int64_t buf_size,
BlockMirrorBackingMode backing_mode,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
bool unmap,
BlockCompletionFunc *cb,
void *opaque,
const BlockJobDriver *driver,
bool is_none_mode, BlockDriverState *base,
bool auto_complete, const char *filter_node_name,
Error **errp)
{
MirrorBlockJob *s;
BlockDriverState *mirror_top_bs;
bool target_graph_mod;
bool target_is_backing;
Error *local_err = NULL;
int ret;
if (granularity == 0) {
granularity = bdrv_get_default_bitmap_granularity(target);
assert ((granularity & (granularity - 1)) == 0);
assert(granularity >= BDRV_SECTOR_SIZE);
if (buf_size < 0) {
error_setg(errp, "Invalid parameter 'buf-size'");
return;
if (buf_size == 0) {
buf_size = DEFAULT_MIRROR_BUF_SIZE;
mirror_top_bs = bdrv_new_open_driver(&bdrv_mirror_top, filter_node_name,
BDRV_O_RDWR, errp);
if (mirror_top_bs == NULL) {
return;
mirror_top_bs->total_sectors = bs->total_sectors;
bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs));
bdrv_ref(mirror_top_bs);
bdrv_drained_begin(bs);
bdrv_append(mirror_top_bs, bs, &local_err);
bdrv_drained_end(bs);
if (local_err) {
bdrv_unref(mirror_top_bs);
error_propagate(errp, local_err);
return;
s = block_job_create(job_id, driver, mirror_top_bs,
BLK_PERM_CONSISTENT_READ,
BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed,
creation_flags, cb, opaque, errp);
if (!s) {
goto fail;
bdrv_unref(mirror_top_bs);
s->source = bs;
s->mirror_top_bs = mirror_top_bs;
target_is_backing = bdrv_chain_contains(bs, target);
target_graph_mod = (backing_mode != MIRROR_LEAVE_BACKING_CHAIN);
s->target = blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE |
(target_graph_mod ? BLK_PERM_GRAPH_MOD : 0),
BLK_PERM_WRITE_UNCHANGED |
(target_is_backing ? BLK_PERM_CONSISTENT_READ |
BLK_PERM_WRITE |
BLK_PERM_GRAPH_MOD : 0));
ret = blk_insert_bs(s->target, target, errp);
if (ret < 0) {
goto fail;
s->replaces = g_strdup(replaces);
s->on_source_error = on_source_error;
s->on_target_error = on_target_error;
s->is_none_mode = is_none_mode;
s->backing_mode = backing_mode;
s->base = base;
s->granularity = granularity;
s->buf_size = ROUND_UP(buf_size, granularity);
s->unmap = unmap;
if (auto_complete) {
s->should_complete = true;
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
if (!s->dirty_bitmap) {
goto fail;
block_job_add_bdrv(&s->common, "target", target, 0, BLK_PERM_ALL,
&error_abort);
if (target_is_backing) {
BlockDriverState *iter;
for (iter = backing_bs(bs); iter != target; iter = backing_bs(iter)) {
ret = block_job_add_bdrv(&s->common, "intermediate node", iter, 0,
BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE,
errp);
if (ret < 0) {
goto fail;
trace_mirror_start(bs, s, opaque);
block_job_start(&s->common);
return;
fail:
if (s) {
bdrv_ref(mirror_top_bs);
g_free(s->replaces);
blk_unref(s->target);
block_job_early_fail(&s->common);
bdrv_child_try_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL,
&error_abort);
bdrv_replace_node(mirror_top_bs, backing_bs(mirror_top_bs), &error_abort);
bdrv_unref(mirror_top_bs);
| 1threat
|
How to write Java Script function in angular 4? : I am newbie to Angular 4. Following function is the one we currently using in asp.net project. Its working perfectly. This function is for change the arrow icon of font awesome.
<script type="text/javascript">
$('.collapse').on('shown.bs.collapse', function () {
$(this).parent().find(".fa-caret-down").removeClass("fa-caret-down").addClass("fa-caret-up");
}).on('hidden.bs.collapse', function () {
$(this).parent().find(".fa-caret-up").removeClass("fa-caret-up").addClass("fa-caret-down");
});
</script>
**How to write the above function in angular 4?**
| 0debug
|
Merge values in map kotlin : <p>I need merge maps <code>mapA</code> and<code>mapB</code> with pairs of "name" - "phone number" into the final map, sticking together the values for duplicate keys, separated by commas. Duplicate values should be added only once.
I need the most idiomatic and correct in terms of language approach.</p>
<p>For example:</p>
<pre><code>val mapA = mapOf("Emergency" to "112", "Fire department" to "101", "Police" to "102")
val mapB = mapOf("Emergency" to "911", "Police" to "102")
</code></pre>
<p>The final result should look like this:</p>
<pre><code>{"Emergency" to "112, 911", "Fire department" to "101", "Police" to "102"}
</code></pre>
<p>This is my function:</p>
<pre><code>fun mergePhoneBooks(mapA: Map<String, String>, mapB: Map<String, String>): Map<String, String> {
val unionList: MutableMap <String, String> = mapA.toMutableMap()
unionList.forEach { (key, value) -> TODO() } // here's I can't come on with a beatiful solution
return unionList
}
</code></pre>
| 0debug
|
OCCI versus JDBC (Incredible Results!!!) : I'm very surprise with a performance test comparing OCCI (Oracle C++ Call Interface) and the old JDBC.
Here is the code:
<pre><code>
#include <iostream>
#include <cstdlib>
#include <occi.h>
using namespace oracle::occi;
using namespace std;
const string username = "system";
const string password = "******";
const string url = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)))";
const string sql = "select * from CREDITO.movtos_cuentas";
int main(int argc, char** argv) {
cout << "Oracle Connectivity" << endl;
Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Connection *conn = env->createConnection(username, password, url);
Statement *stm = conn->createStatement(sql);
ResultSet *rs = stm->executeQuery();
unsigned long count = 0;
while (rs->next()) {
count++;
}
stm->closeResultSet(rs);
conn->terminateStatement(stm);
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
cout << "Registros na CREDITO.MOVTOS_CUENTAS: " << count << endl;
return 0;
}
</code></pre>
And here is Java code:
<pre><code>
package oraconnect.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class OraconnectJdbc {
public static void main(String[] args) {
Connection conn = null;
Statement stm = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@127.0.0.1:1521:xe", "system", "******");
stm = conn.createStatement();
rs = stm.executeQuery("select * from CREDITO.movtos_cuentas");
long count = 0;
while (rs.next()) {
count++;
}
System.out.printf("Registros na CREDITO.MOVTOS_CUENTAS: %d\n", count);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
//Ignore
}
}
if (stm != null) {
try {
stm.close();
} catch (SQLException e) {
//Ignore
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
//Ignore
}
}
}
}
}
</code></pre>
I suspect that have made a mistake or use bad practices with C++ version.
Any body can help me to understand this result!?!?!?
| 0debug
|
static int msf_probe(AVProbeData *p)
{
if (memcmp(p->buf, "MSF", 3))
return 0;
if (AV_RB32(p->buf+8) <= 0)
return 0;
if (AV_RB32(p->buf+16) <= 0)
return 0;
return AVPROBE_SCORE_MAX / 3 * 2;
}
| 1threat
|
how to bringback an object to its original position after rotation in unity? : i have created a project where a cube is rotated when we touch on it. **i want the cube to return back to its original position** **when the user stopped touching the cube**. here below i have added the source code of rotating a cube.
please do reply.
>
**SOURCE CODE:-**
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(MeshRenderer))]
public class dr : MonoBehaviour
{
#region ROTATE
private float _sensitivity = 1f;
private Vector3 _mouseReference;
private Vector3 _mouseOffset;
private Vector3 _rotation = Vector3.zero;
private bool _isRotating;
#endregion
void Update()
{
if(_isRotating)
{
// offset
_mouseOffset = (Input.mousePosition - _mouseReference); // apply rotation
_rotation.y = -(_mouseOffset.x + _mouseOffset.y) * _sensitivity; // rotate
gameObject.transform.Rotate(_rotation); // store new mouse position
_mouseReference = Input.mousePosition;
}
}
void OnMouseDown()
{
// rotating flag
_isRotating = true;
// store mouse position
_mouseReference = Input.mousePosition;
}
void OnMouseUp()
{
// rotating flag
_isRotating = false;
}
}
| 0debug
|
static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
DVVideoContext *s = c->priv_data;
int ret;
s->sys = avpriv_dv_codec_profile(c);
if (!s->sys || ff_dv_init_dynamic_tables(s->sys))
return -1;
if ((ret = ff_alloc_packet(pkt, s->sys->frame_size)) < 0) {
av_log(c, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
c->pix_fmt = s->sys->pix_fmt;
s->frame = frame;
c->coded_frame->key_frame = 1;
c->coded_frame->pict_type = AV_PICTURE_TYPE_I;
s->buf = pkt->data;
c->execute(c, dv_encode_video_segment, s->sys->work_chunks, NULL,
dv_work_pool_size(s->sys), sizeof(DVwork_chunk));
emms_c();
dv_format_frame(s, pkt->data);
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat
|
how to match 2 criteria in marco : I currently have the following codes that look up the column for Columbus. But how do I specify that I only want to look up the column for Columbus in Ohio by also referring to row 4 (State)?
Amount = WorksheetFunction.Match("Columbus", Rows("5:5"), 0)
Thank you !
| 0debug
|
Git Extensions: Squash commits? : <p>To squash multiple commits, I have always used:</p>
<pre><code>git reset --soft HEAD~<number of commits to squash> && git commit
</code></pre>
<p>But I wonder if there is a good way to do this in a good git client like git extensions? It would be cool if you could just select consecutive commits and squash them.</p>
| 0debug
|
int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
{
const SPS *sps;
const PPS *pps;
unsigned int first_mb_in_slice;
unsigned int pps_id;
int ret;
unsigned int slice_type, tmp, i, j;
int last_pic_structure, last_pic_droppable;
int needs_reinit = 0;
int field_pic_flag, bottom_field_flag;
int frame_num, droppable, picture_structure;
int mb_aff_frame = 0;
h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
first_mb_in_slice = get_ue_golomb(&sl->gb);
if (first_mb_in_slice == 0) {
if (h->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) {
ff_h264_field_end(h, sl, 1);
}
h->current_slice = 0;
if (!h->first_field) {
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
}
h->cur_pic_ptr = NULL;
}
}
slice_type = get_ue_golomb_31(&sl->gb);
if (slice_type > 9) {
av_log(h->avctx, AV_LOG_ERROR,
"slice type %d too large at %d\n",
slice_type, first_mb_in_slice);
return AVERROR_INVALIDDATA;
}
if (slice_type > 4) {
slice_type -= 5;
sl->slice_type_fixed = 1;
} else
sl->slice_type_fixed = 0;
slice_type = ff_h264_golomb_to_pict_type[slice_type];
sl->slice_type = slice_type;
sl->slice_type_nos = slice_type & 3;
if (h->nal_unit_type == NAL_IDR_SLICE &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) {
av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n");
return AVERROR_INVALIDDATA;
}
if (!h->setup_finished)
h->pict_type = sl->slice_type;
pps_id = get_ue_golomb(&sl->gb);
if (pps_id >= MAX_PPS_COUNT) {
av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
return AVERROR_INVALIDDATA;
}
if (!h->ps.pps_list[pps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing PPS %u referenced\n",
pps_id);
return AVERROR_INVALIDDATA;
}
if (!h->setup_finished) {
h->ps.pps = (const PPS*)h->ps.pps_list[pps_id]->data;
} else if (h->ps.pps != (const PPS*)h->ps.pps_list[pps_id]->data) {
av_log(h->avctx, AV_LOG_ERROR, "PPS changed between slices\n");
return AVERROR_INVALIDDATA;
}
if (!h->ps.sps_list[h->ps.pps->sps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n",
h->ps.pps->sps_id);
return AVERROR_INVALIDDATA;
}
if (h->ps.sps != (const SPS*)h->ps.sps_list[h->ps.pps->sps_id]->data) {
h->ps.sps = (SPS*)h->ps.sps_list[h->ps.pps->sps_id]->data;
if (h->bit_depth_luma != h->ps.sps->bit_depth_luma ||
h->chroma_format_idc != h->ps.sps->chroma_format_idc)
needs_reinit = 1;
if (h->flags & AV_CODEC_FLAG_LOW_DELAY ||
(h->ps.sps->bitstream_restriction_flag &&
!h->ps.sps->num_reorder_frames)) {
if (h->avctx->has_b_frames > 1 || h->delayed_pic[0])
av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. "
"Reenabling low delay requires a codec flush.\n");
else
h->low_delay = 1;
}
if (h->avctx->has_b_frames < 2)
h->avctx->has_b_frames = !h->low_delay;
}
pps = h->ps.pps;
sps = h->ps.sps;
if (!h->setup_finished) {
h->avctx->profile = ff_h264_get_profile(sps);
h->avctx->level = sps->level_idc;
h->avctx->refs = sps->ref_frame_count;
if (h->mb_width != sps->mb_width ||
h->mb_height != sps->mb_height * (2 - sps->frame_mbs_only_flag))
needs_reinit = 1;
h->mb_width = sps->mb_width;
h->mb_height = sps->mb_height * (2 - sps->frame_mbs_only_flag);
h->mb_num = h->mb_width * h->mb_height;
h->mb_stride = h->mb_width + 1;
h->b_stride = h->mb_width * 4;
h->chroma_y_shift = sps->chroma_format_idc <= 1;
h->width = 16 * h->mb_width;
h->height = 16 * h->mb_height;
ret = init_dimensions(h);
if (ret < 0)
return ret;
if (sps->video_signal_type_present_flag) {
h->avctx->color_range = sps->full_range ? AVCOL_RANGE_JPEG
: AVCOL_RANGE_MPEG;
if (sps->colour_description_present_flag) {
if (h->avctx->colorspace != sps->colorspace)
needs_reinit = 1;
h->avctx->color_primaries = sps->color_primaries;
h->avctx->color_trc = sps->color_trc;
h->avctx->colorspace = sps->colorspace;
}
}
}
if (h->context_initialized && needs_reinit) {
h->context_initialized = 0;
if (sl != h->slice_ctx) {
av_log(h->avctx, AV_LOG_ERROR,
"changing width %d -> %d / height %d -> %d on "
"slice %d\n",
h->width, h->avctx->coded_width,
h->height, h->avctx->coded_height,
h->current_slice + 1);
return AVERROR_INVALIDDATA;
}
ff_h264_flush_change(h);
if ((ret = get_pixel_format(h)) < 0)
return ret;
h->avctx->pix_fmt = ret;
av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
"pix_fmt: %d\n", h->width, h->height, h->avctx->pix_fmt);
if ((ret = h264_slice_header_init(h)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
if (!h->context_initialized) {
if (sl != h->slice_ctx) {
av_log(h->avctx, AV_LOG_ERROR,
"Cannot (re-)initialize context during parallel decoding.\n");
return AVERROR_PATCHWELCOME;
}
if ((ret = get_pixel_format(h)) < 0)
return ret;
h->avctx->pix_fmt = ret;
if ((ret = h264_slice_header_init(h)) < 0) {
av_log(h->avctx, AV_LOG_ERROR,
"h264_slice_header_init() failed\n");
return ret;
}
}
frame_num = get_bits(&sl->gb, sps->log2_max_frame_num);
if (!h->setup_finished)
h->frame_num = frame_num;
sl->mb_mbaff = 0;
last_pic_structure = h->picture_structure;
last_pic_droppable = h->droppable;
droppable = h->nal_ref_idc == 0;
if (sps->frame_mbs_only_flag) {
picture_structure = PICT_FRAME;
} else {
field_pic_flag = get_bits1(&sl->gb);
if (field_pic_flag) {
bottom_field_flag = get_bits1(&sl->gb);
picture_structure = PICT_TOP_FIELD + bottom_field_flag;
} else {
picture_structure = PICT_FRAME;
mb_aff_frame = sps->mb_aff;
}
}
if (!h->setup_finished) {
h->droppable = droppable;
h->picture_structure = picture_structure;
h->mb_aff_frame = mb_aff_frame;
}
sl->mb_field_decoding_flag = h->picture_structure != PICT_FRAME;
if (h->current_slice != 0) {
if (last_pic_structure != picture_structure ||
last_pic_droppable != droppable) {
av_log(h->avctx, AV_LOG_ERROR,
"Changing field mode (%d -> %d) between slices is not allowed\n",
last_pic_structure, h->picture_structure);
return AVERROR_INVALIDDATA;
} else if (!h->cur_pic_ptr) {
av_log(h->avctx, AV_LOG_ERROR,
"unset cur_pic_ptr on slice %d\n",
h->current_slice + 1);
return AVERROR_INVALIDDATA;
}
} else {
if (h->frame_num != h->prev_frame_num) {
int unwrap_prev_frame_num = h->prev_frame_num;
int max_frame_num = 1 << sps->log2_max_frame_num;
if (unwrap_prev_frame_num > h->frame_num)
unwrap_prev_frame_num -= max_frame_num;
if ((h->frame_num - unwrap_prev_frame_num) > sps->ref_frame_count) {
unwrap_prev_frame_num = (h->frame_num - sps->ref_frame_count) - 1;
if (unwrap_prev_frame_num < 0)
unwrap_prev_frame_num += max_frame_num;
h->prev_frame_num = unwrap_prev_frame_num;
}
}
if (h->first_field) {
assert(h->cur_pic_ptr);
assert(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (h->cur_pic_ptr->frame_num != h->frame_num) {
if (!last_pic_droppable && last_pic_structure != PICT_FRAME) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
last_pic_structure == PICT_TOP_FIELD);
}
} else {
if (!((last_pic_structure == PICT_TOP_FIELD &&
h->picture_structure == PICT_BOTTOM_FIELD) ||
(last_pic_structure == PICT_BOTTOM_FIELD &&
h->picture_structure == PICT_TOP_FIELD))) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid field mode combination %d/%d\n",
last_pic_structure, h->picture_structure);
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_INVALIDDATA;
} else if (last_pic_droppable != h->droppable) {
avpriv_request_sample(h->avctx,
"Found reference and non-reference fields in the same frame, which");
h->picture_structure = last_pic_structure;
h->droppable = last_pic_droppable;
return AVERROR_PATCHWELCOME;
}
}
}
}
while (h->frame_num != h->prev_frame_num &&
h->frame_num != (h->prev_frame_num + 1) % (1 << sps->log2_max_frame_num)) {
H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
h->frame_num, h->prev_frame_num);
ret = initialize_cur_frame(h);
if (ret < 0) {
h->first_field = 0;
return ret;
}
h->prev_frame_num++;
h->prev_frame_num %= 1 << sps->log2_max_frame_num;
h->cur_pic_ptr->frame_num = h->prev_frame_num;
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0);
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1);
ret = ff_generate_sliding_window_mmcos(h, 1);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if (h->short_ref_count) {
if (prev &&
h->short_ref[0]->f->width == prev->f->width &&
h->short_ref[0]->f->height == prev->f->height &&
h->short_ref[0]->f->format == prev->f->format) {
av_image_copy(h->short_ref[0]->f->data,
h->short_ref[0]->f->linesize,
(const uint8_t **)prev->f->data,
prev->f->linesize,
prev->f->format,
h->mb_width * 16,
h->mb_height * 16);
h->short_ref[0]->poc = prev->poc + 2;
}
h->short_ref[0]->frame_num = h->prev_frame_num;
}
}
if (h->first_field) {
assert(h->cur_pic_ptr);
assert(h->cur_pic_ptr->f->buf[0]);
assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF);
if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) {
h->cur_pic_ptr = NULL;
h->first_field = FIELD_PICTURE(h);
} else {
if (h->cur_pic_ptr->frame_num != h->frame_num) {
h->first_field = 1;
h->cur_pic_ptr = NULL;
} else {
h->first_field = 0;
}
}
} else {
h->first_field = FIELD_PICTURE(h);
}
if (!FIELD_PICTURE(h) || h->first_field) {
if (h264_frame_start(h) < 0) {
h->first_field = 0;
return AVERROR_INVALIDDATA;
}
} else {
release_unused_pictures(h, 0);
}
}
assert(h->mb_num == h->mb_width * h->mb_height);
if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num ||
first_mb_in_slice >= h->mb_num) {
av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return AVERROR_INVALIDDATA;
}
sl->resync_mb_x = sl->mb_x = first_mb_in_slice % h->mb_width;
sl->resync_mb_y = sl->mb_y = (first_mb_in_slice / h->mb_width) <<
FIELD_OR_MBAFF_PICTURE(h);
if (h->picture_structure == PICT_BOTTOM_FIELD)
sl->resync_mb_y = sl->mb_y = sl->mb_y + 1;
assert(sl->mb_y < h->mb_height);
if (h->picture_structure == PICT_FRAME) {
h->curr_pic_num = h->frame_num;
h->max_pic_num = 1 << sps->log2_max_frame_num;
} else {
h->curr_pic_num = 2 * h->frame_num + 1;
h->max_pic_num = 1 << (sps->log2_max_frame_num + 1);
}
if (h->nal_unit_type == NAL_IDR_SLICE)
get_ue_golomb(&sl->gb);
if (sps->poc_type == 0) {
int poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);
if (!h->setup_finished)
h->poc_lsb = poc_lsb;
if (pps->pic_order_present == 1 && h->picture_structure == PICT_FRAME) {
int delta_poc_bottom = get_se_golomb(&sl->gb);
if (!h->setup_finished)
h->delta_poc_bottom = delta_poc_bottom;
}
}
if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) {
int delta_poc = get_se_golomb(&sl->gb);
if (!h->setup_finished)
h->delta_poc[0] = delta_poc;
if (pps->pic_order_present == 1 && h->picture_structure == PICT_FRAME) {
delta_poc = get_se_golomb(&sl->gb);
if (!h->setup_finished)
h->delta_poc[1] = delta_poc;
}
}
if (!h->setup_finished)
ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc);
if (pps->redundant_pic_cnt_present)
sl->redundant_pic_count = get_ue_golomb(&sl->gb);
if (sl->slice_type_nos == AV_PICTURE_TYPE_B)
sl->direct_spatial_mv_pred = get_bits1(&sl->gb);
ret = ff_h264_parse_ref_count(&sl->list_count, sl->ref_count,
&sl->gb, pps, sl->slice_type_nos,
h->picture_structure);
if (ret < 0)
return ret;
if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
ret = ff_h264_decode_ref_pic_list_reordering(h, sl);
if (ret < 0) {
sl->ref_count[1] = sl->ref_count[0] = 0;
return ret;
}
}
if ((pps->weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) ||
(pps->weighted_bipred_idc == 1 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B))
ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count,
sl->slice_type_nos, &sl->pwt);
else if (pps->weighted_bipred_idc == 2 &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, -1);
} else {
sl->pwt.use_weight = 0;
for (i = 0; i < 2; i++) {
sl->pwt.luma_weight_flag[i] = 0;
sl->pwt.chroma_weight_flag[i] = 0;
}
}
if (h->nal_ref_idc) {
ret = ff_h264_decode_ref_pic_marking(h, &sl->gb,
!(h->avctx->active_thread_type & FF_THREAD_FRAME) ||
h->current_slice == 0);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
return AVERROR_INVALIDDATA;
}
if (FRAME_MBAFF(h)) {
ff_h264_fill_mbaff_ref_list(h, sl);
if (pps->weighted_bipred_idc == 2 && sl->slice_type_nos == AV_PICTURE_TYPE_B) {
implicit_weight_table(h, sl, 0);
implicit_weight_table(h, sl, 1);
}
}
if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred)
ff_h264_direct_dist_scale_factor(h, sl);
ff_h264_direct_ref_list_init(h, sl);
if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) {
tmp = get_ue_golomb_31(&sl->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->cabac_init_idc = tmp;
}
sl->last_qscale_diff = 0;
tmp = pps->init_qp + get_se_golomb(&sl->gb);
if (tmp > 51 + 6 * (sps->bit_depth_luma - 8)) {
av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->qscale = tmp;
sl->chroma_qp[0] = get_chroma_qp(h, 0, sl->qscale);
sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale);
if (sl->slice_type == AV_PICTURE_TYPE_SP)
get_bits1(&sl->gb);
if (sl->slice_type == AV_PICTURE_TYPE_SP ||
sl->slice_type == AV_PICTURE_TYPE_SI)
get_se_golomb(&sl->gb);
sl->deblocking_filter = 1;
sl->slice_alpha_c0_offset = 0;
sl->slice_beta_offset = 0;
if (pps->deblocking_filter_parameters_present) {
tmp = get_ue_golomb_31(&sl->gb);
if (tmp > 2) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking_filter_idc %u out of range\n", tmp);
return AVERROR_INVALIDDATA;
}
sl->deblocking_filter = tmp;
if (sl->deblocking_filter < 2)
sl->deblocking_filter ^= 1;
if (sl->deblocking_filter) {
sl->slice_alpha_c0_offset = get_se_golomb(&sl->gb) * 2;
sl->slice_beta_offset = get_se_golomb(&sl->gb) * 2;
if (sl->slice_alpha_c0_offset > 12 ||
sl->slice_alpha_c0_offset < -12 ||
sl->slice_beta_offset > 12 ||
sl->slice_beta_offset < -12) {
av_log(h->avctx, AV_LOG_ERROR,
"deblocking filter parameters %d %d out of range\n",
sl->slice_alpha_c0_offset, sl->slice_beta_offset);
return AVERROR_INVALIDDATA;
}
}
}
if (h->avctx->skip_loop_filter >= AVDISCARD_ALL ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
sl->slice_type_nos != AV_PICTURE_TYPE_I) ||
(h->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
sl->slice_type_nos == AV_PICTURE_TYPE_B) ||
(h->avctx->skip_loop_filter >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0))
sl->deblocking_filter = 0;
if (sl->deblocking_filter == 1 && h->max_contexts > 1) {
if (h->avctx->flags2 & AV_CODEC_FLAG2_FAST) {
sl->deblocking_filter = 2;
} else {
h->max_contexts = 1;
if (!h->single_decode_warning) {
av_log(h->avctx, AV_LOG_INFO,
"Cannot parallelize deblocking type 1, decoding such frames in sequential order\n");
h->single_decode_warning = 1;
}
if (sl != h->slice_ctx) {
av_log(h->avctx, AV_LOG_ERROR,
"Deblocking switched inside frame.\n");
return 1;
}
}
}
sl->qp_thresh = 15 -
FFMIN(sl->slice_alpha_c0_offset, sl->slice_beta_offset) -
FFMAX3(0,
pps->chroma_qp_index_offset[0],
pps->chroma_qp_index_offset[1]) +
6 * (sps->bit_depth_luma - 8);
sl->slice_num = ++h->current_slice;
if (sl->slice_num >= MAX_SLICES) {
av_log(h->avctx, AV_LOG_ERROR,
"Too many slices, increase MAX_SLICES and recompile\n");
}
for (j = 0; j < 2; j++) {
int id_list[16];
int *ref2frm = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j];
for (i = 0; i < 16; i++) {
id_list[i] = 60;
if (j < sl->list_count && i < sl->ref_count[j] &&
sl->ref_list[j][i].parent->f->buf[0]) {
int k;
AVBuffer *buf = sl->ref_list[j][i].parent->f->buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f->buf[0]->buffer == buf) {
id_list[i] = k;
break;
}
for (k = 0; k < h->long_ref_count; k++)
if (h->long_ref[k] && h->long_ref[k]->f->buf[0]->buffer == buf) {
id_list[i] = h->short_ref_count + k;
break;
}
}
}
ref2frm[0] =
ref2frm[1] = -1;
for (i = 0; i < 16; i++)
ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3);
ref2frm[18 + 0] =
ref2frm[18 + 1] = -1;
for (i = 16; i < 48; i++)
ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] +
(sl->ref_list[j][i].reference & 3);
}
if (h->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(h->avctx, AV_LOG_DEBUG,
"slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
sl->slice_num,
(h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
av_get_picture_type_char(sl->slice_type),
sl->slice_type_fixed ? " fix" : "",
h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "",
pps_id, h->frame_num,
h->cur_pic_ptr->field_poc[0],
h->cur_pic_ptr->field_poc[1],
sl->ref_count[0], sl->ref_count[1],
sl->qscale,
sl->deblocking_filter,
sl->slice_alpha_c0_offset, sl->slice_beta_offset,
sl->pwt.use_weight,
sl->pwt.use_weight == 1 && sl->pwt.use_weight_chroma ? "c" : "",
sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
}
return 0;
}
| 1threat
|
static void pci_grackle_class_init(ObjectClass *klass, void *data)
{
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
k->init = pci_grackle_init_device;
dc->no_user = 1;
}
| 1threat
|
int av_get_cpu_flags(void)
{
if (checked)
return flags;
if (ARCH_AARCH64)
flags = ff_get_cpu_flags_aarch64();
if (ARCH_ARM)
flags = ff_get_cpu_flags_arm();
if (ARCH_PPC)
flags = ff_get_cpu_flags_ppc();
if (ARCH_X86)
flags = ff_get_cpu_flags_x86();
checked = 1;
return flags;
}
| 1threat
|
static void gen_arith(DisasContext *ctx, uint32_t opc,
int rd, int rs, int rt)
{
const char *opn = "arith";
if (rd == 0 && opc != OPC_ADD && opc != OPC_SUB
&& opc != OPC_DADD && opc != OPC_DSUB) {
MIPS_DEBUG("NOP");
return;
}
switch (opc) {
case OPC_ADD:
{
TCGv t0 = tcg_temp_local_new();
TCGv t1 = tcg_temp_new();
TCGv t2 = tcg_temp_new();
int l1 = gen_new_label();
gen_load_gpr(t1, rs);
gen_load_gpr(t2, rt);
tcg_gen_add_tl(t0, t1, t2);
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_xor_tl(t1, t1, t2);
tcg_gen_xor_tl(t2, t0, t2);
tcg_gen_andc_tl(t1, t2, t1);
tcg_temp_free(t2);
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l1);
tcg_temp_free(t1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
opn = "add";
break;
case OPC_ADDU:
if (rs != 0 && rt != 0) {
tcg_gen_add_tl(cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]);
tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
} else if (rs == 0 && rt != 0) {
tcg_gen_mov_tl(cpu_gpr[rd], cpu_gpr[rt]);
} else if (rs != 0 && rt == 0) {
tcg_gen_mov_tl(cpu_gpr[rd], cpu_gpr[rs]);
} else {
tcg_gen_movi_tl(cpu_gpr[rd], 0);
}
opn = "addu";
break;
case OPC_SUB:
{
TCGv t0 = tcg_temp_local_new();
TCGv t1 = tcg_temp_new();
TCGv t2 = tcg_temp_new();
int l1 = gen_new_label();
gen_load_gpr(t1, rs);
gen_load_gpr(t2, rt);
tcg_gen_sub_tl(t0, t1, t2);
tcg_gen_ext32s_tl(t0, t0);
tcg_gen_xor_tl(t2, t1, t2);
tcg_gen_xor_tl(t1, t0, t1);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l1);
tcg_temp_free(t1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
opn = "sub";
break;
case OPC_SUBU:
if (rs != 0 && rt != 0) {
tcg_gen_sub_tl(cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]);
tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
} else if (rs == 0 && rt != 0) {
tcg_gen_neg_tl(cpu_gpr[rd], cpu_gpr[rt]);
tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
} else if (rs != 0 && rt == 0) {
tcg_gen_mov_tl(cpu_gpr[rd], cpu_gpr[rs]);
} else {
tcg_gen_movi_tl(cpu_gpr[rd], 0);
}
opn = "subu";
break;
#if defined(TARGET_MIPS64)
case OPC_DADD:
{
TCGv t0 = tcg_temp_local_new();
TCGv t1 = tcg_temp_new();
TCGv t2 = tcg_temp_new();
int l1 = gen_new_label();
gen_load_gpr(t1, rs);
gen_load_gpr(t2, rt);
tcg_gen_add_tl(t0, t1, t2);
tcg_gen_xor_tl(t1, t1, t2);
tcg_gen_xor_tl(t2, t0, t2);
tcg_gen_andc_tl(t1, t2, t1);
tcg_temp_free(t2);
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l1);
tcg_temp_free(t1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
opn = "dadd";
break;
case OPC_DADDU:
if (rs != 0 && rt != 0) {
tcg_gen_add_tl(cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]);
} else if (rs == 0 && rt != 0) {
tcg_gen_mov_tl(cpu_gpr[rd], cpu_gpr[rt]);
} else if (rs != 0 && rt == 0) {
tcg_gen_mov_tl(cpu_gpr[rd], cpu_gpr[rs]);
} else {
tcg_gen_movi_tl(cpu_gpr[rd], 0);
}
opn = "daddu";
break;
case OPC_DSUB:
{
TCGv t0 = tcg_temp_local_new();
TCGv t1 = tcg_temp_new();
TCGv t2 = tcg_temp_new();
int l1 = gen_new_label();
gen_load_gpr(t1, rs);
gen_load_gpr(t2, rt);
tcg_gen_sub_tl(t0, t1, t2);
tcg_gen_xor_tl(t2, t1, t2);
tcg_gen_xor_tl(t1, t0, t1);
tcg_gen_and_tl(t1, t1, t2);
tcg_temp_free(t2);
tcg_gen_brcondi_tl(TCG_COND_GE, t1, 0, l1);
tcg_temp_free(t1);
generate_exception(ctx, EXCP_OVERFLOW);
gen_set_label(l1);
gen_store_gpr(t0, rd);
tcg_temp_free(t0);
}
opn = "dsub";
break;
case OPC_DSUBU:
if (rs != 0 && rt != 0) {
tcg_gen_sub_tl(cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]);
} else if (rs == 0 && rt != 0) {
tcg_gen_neg_tl(cpu_gpr[rd], cpu_gpr[rt]);
} else if (rs != 0 && rt == 0) {
tcg_gen_mov_tl(cpu_gpr[rd], cpu_gpr[rs]);
} else {
tcg_gen_movi_tl(cpu_gpr[rd], 0);
}
opn = "dsubu";
break;
#endif
case OPC_MUL:
if (likely(rs != 0 && rt != 0)) {
tcg_gen_mul_tl(cpu_gpr[rd], cpu_gpr[rs], cpu_gpr[rt]);
tcg_gen_ext32s_tl(cpu_gpr[rd], cpu_gpr[rd]);
} else {
tcg_gen_movi_tl(cpu_gpr[rd], 0);
}
opn = "mul";
break;
}
(void)opn;
MIPS_DEBUG("%s %s, %s, %s", opn, regnames[rd], regnames[rs], regnames[rt]);
}
| 1threat
|
static int gif_read_extension(GifState *s)
{
int ext_code, ext_len, gce_flags, gce_transparent_index;
if (bytestream2_get_bytes_left(&s->gb) < 2)
return AVERROR_INVALIDDATA;
ext_code = bytestream2_get_byteu(&s->gb);
ext_len = bytestream2_get_byteu(&s->gb);
av_dlog(s->avctx, "ext_code=0x%x len=%d\n", ext_code, ext_len);
switch(ext_code) {
case GIF_GCE_EXT_LABEL:
if (ext_len != 4)
goto discard_ext;
if (bytestream2_get_bytes_left(&s->gb) < 5)
return AVERROR_INVALIDDATA;
gce_flags = bytestream2_get_byteu(&s->gb);
bytestream2_skipu(&s->gb, 2);
gce_transparent_index = bytestream2_get_byteu(&s->gb);
if (gce_flags & 0x01)
s->transparent_color_index = gce_transparent_index;
else
s->transparent_color_index = -1;
s->gce_disposal = (gce_flags >> 2) & 0x7;
av_dlog(s->avctx, "gce_flags=%x tcolor=%d disposal=%d\n",
gce_flags,
s->transparent_color_index, s->gce_disposal);
if (s->gce_disposal > 3) {
s->gce_disposal = GCE_DISPOSAL_NONE;
av_dlog(s->avctx, "invalid value in gce_disposal (%d). Using default value of 0.\n", ext_len);
}
ext_len = bytestream2_get_byteu(&s->gb);
break;
}
discard_ext:
while (ext_len != 0) {
if (bytestream2_get_bytes_left(&s->gb) < ext_len + 1)
return AVERROR_INVALIDDATA;
bytestream2_skipu(&s->gb, ext_len);
ext_len = bytestream2_get_byteu(&s->gb);
av_dlog(s->avctx, "ext_len1=%d\n", ext_len);
}
return 0;
}
| 1threat
|
Why variable return a NULL value in external script.js file? : <p>I'm try to create a clickable button in my webpage using Javascript, First i'm writing index.html (html, css, javascript all together) then it was work fine. Here is my first code: </p>
<pre><code> <!DOCTYPE html>
<html>
<head>
<title>LearnVariable</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<button>PressMe</button>
<script>
var button = document.querySelector('button');
button.onclick = function(){
var name = prompt('What is your Name');
}
</script>
</body>
</html>
</code></pre>
<p>Then i'm try to write my javascript code in different file name <strong>script.js</strong> and Link this file with head section and cut my script part from body section .Then it occur a error that say that <strong>TypeError: button is null</strong> .
Here is my <strong>index.html</strong> code :</p>
<pre><code> <!DOCTYPE html>
<html>
<head>
<title>LearnVariable</title>
<script src="script.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<button>PressMe</button>
</body>
</html>
</code></pre>
<p>And This is my <strong>script.js</strong> code:</p>
<pre><code>var button = document.querySelector('button');
button.onclick = function(){
var name = prompt('What is your Name');
}
</code></pre>
<p>I'm try to find the bug by myself and search internet then they said that use console.log(button) to figure out the error, but i didn't find how to solve this.</p>
| 0debug
|
What does "shotgun parser" mean? : <p>Heard this term in talk <a href="https://www.youtube.com/watch?v=3kEfedtQVOY" rel="noreferrer">The Science of Insecurity</a> but I am not sure what does it mean.</p>
| 0debug
|
static void init_frame_decoder(APEContext *ctx)
{
int i;
init_entropy_decoder(ctx);
init_predictor_decoder(ctx);
for (i = 0; i < APE_FILTER_LEVELS; i++) {
if (!ape_filter_orders[ctx->fset][i])
break;
init_filter(ctx, ctx->filters[i], ctx->filterbuf[i],
ape_filter_orders[ctx->fset][i]);
}
}
| 1threat
|
How can I create a volume for the current user home directory in docker-compose? : <p>For the docker image <code>v2tec/watchtower</code> I must provide the user-specific docker configuration file <code>config.json</code>. I am currently doing this as following:</p>
<pre><code>version: "3"
services:
watchtower:
image: v2tec/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/thefrozenyoghurt/.docker/config.json:/config.json
</code></pre>
<p>This works on my machine. But I want to distribute this <code>docker-compose.yml</code> to my colleagues so they can use it also. This won't work with the <code>docker-compose.yml</code> above, as my home directory is hardcoded.</p>
<p>Is it possible to refer to the user home directory in a <code>docker-compose.yml</code>? I cannot find such functionalities in the documentation. I think I need something like:</p>
<pre><code>version: "3"
services:
watchtower:
image: v2tec/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $HOME/.docker/config.json:/config.json
</code></pre>
| 0debug
|
abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
abi_ulong new_size, unsigned long flags,
abi_ulong new_addr)
{
int prot;
void *host_addr;
mmap_lock();
if (flags & MREMAP_FIXED) {
host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
old_size, new_size,
flags,
g2h(new_addr));
if (RESERVED_VA && host_addr != MAP_FAILED) {
mmap_reserve(old_addr, old_size);
}
} else if (flags & MREMAP_MAYMOVE) {
abi_ulong mmap_start;
mmap_start = mmap_find_vma(0, new_size);
if (mmap_start == -1) {
errno = ENOMEM;
host_addr = MAP_FAILED;
} else {
host_addr = (void *) syscall(__NR_mremap, g2h(old_addr),
old_size, new_size,
flags | MREMAP_FIXED,
g2h(mmap_start));
mmap_reserve(old_addr, old_size);
}
} else {
int prot = 0;
if (RESERVED_VA && old_size < new_size) {
abi_ulong addr;
for (addr = old_addr + old_size;
addr < old_addr + new_size;
addr++) {
prot |= page_get_flags(addr);
}
}
if (prot == 0) {
host_addr = mremap(g2h(old_addr), old_size, new_size, flags);
if (host_addr != MAP_FAILED && RESERVED_VA && old_size > new_size) {
mmap_reserve(old_addr + old_size, new_size - old_size);
}
} else {
errno = ENOMEM;
host_addr = MAP_FAILED;
}
if ((unsigned long)host_addr + new_size > (abi_ulong)-1) {
host_addr = mremap(g2h(old_addr), new_size, old_size, flags);
errno = ENOMEM;
host_addr = MAP_FAILED;
}
}
if (host_addr == MAP_FAILED) {
new_addr = -1;
} else {
new_addr = h2g(host_addr);
prot = page_get_flags(old_addr);
page_set_flags(old_addr, old_addr + old_size, 0);
page_set_flags(new_addr, new_addr + new_size, prot | PAGE_VALID);
}
mmap_unlock();
return new_addr;
}
| 1threat
|
static void avc_wgt_4x2_msa(uint8_t *data,
int32_t stride,
int32_t log2_denom,
int32_t src_weight,
int32_t offset_in)
{
uint32_t data0, data1;
v16u8 zero = { 0 };
v16u8 src0, src1;
v4i32 res0, res1;
v8i16 temp0, temp1;
v16u8 vec0, vec1;
v8i16 wgt, denom, offset;
offset_in <<= (log2_denom);
if (log2_denom) {
offset_in += (1 << (log2_denom - 1));
}
wgt = __msa_fill_h(src_weight);
offset = __msa_fill_h(offset_in);
denom = __msa_fill_h(log2_denom);
data0 = LOAD_WORD(data);
data1 = LOAD_WORD(data + stride);
src0 = (v16u8) __msa_fill_w(data0);
src1 = (v16u8) __msa_fill_w(data1);
ILVR_B_2VECS_UB(src0, src1, zero, zero, vec0, vec1);
temp0 = wgt * (v8i16) vec0;
temp1 = wgt * (v8i16) vec1;
temp0 = __msa_adds_s_h(temp0, offset);
temp1 = __msa_adds_s_h(temp1, offset);
temp0 = __msa_maxi_s_h(temp0, 0);
temp1 = __msa_maxi_s_h(temp1, 0);
temp0 = __msa_srl_h(temp0, denom);
temp1 = __msa_srl_h(temp1, denom);
temp0 = (v8i16) __msa_sat_u_h((v8u16) temp0, 7);
temp1 = (v8i16) __msa_sat_u_h((v8u16) temp1, 7);
res0 = (v4i32) __msa_pckev_b((v16i8) temp0, (v16i8) temp0);
res1 = (v4i32) __msa_pckev_b((v16i8) temp1, (v16i8) temp1);
data0 = __msa_copy_u_w(res0, 0);
data1 = __msa_copy_u_w(res1, 0);
STORE_WORD(data, data0);
data += stride;
STORE_WORD(data, data1);
}
| 1threat
|
static void test_validate_fail_struct_nested(TestInputVisitorData *data,
const void *unused)
{
UserDefNested *udp = NULL;
Error *err = NULL;
Visitor *v;
v = validate_test_init(data, "{ 'string0': 'string0', 'dict1': { 'string1': 'string1', 'dict2': { 'userdef1': { 'integer': 42, 'string': 'string', 'extra': [42, 23, {'foo':'bar'}] }, 'string2': 'string2'}}}");
visit_type_UserDefNested(v, &udp, NULL, &err);
g_assert(err);
qapi_free_UserDefNested(udp);
}
| 1threat
|
How to rotate 45% arrow icon using blow css tricks? : Here what i need to do is rotate 45% using below CSS tricks and here i included what i have tried,
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.hero {
position:relative;
}
.hero:after,
.hero:after {
z-index: -1;
position: absolute;
top: 98.1%;
left: 70%;
margin-left: -25%;
content: '';
width: 0;
height: 0;
border-bottom: solid 50px #e15915;
border-left: solid 50px transparent;
border-right: solid 50px transparent;
}
<!-- language: lang-html -->
<div class="hero"></div>
<!-- end snippet -->
| 0debug
|
Find occurrences of huge list of phrases in text : <p>I'm building a backend and trying to crunch the following problem.</p>
<ul>
<li>The clients submit text to the backend (around <code>2000</code> characters on average)</li>
<li>Backend endpoint that receives the request has to apply phrase highlighting to the submitted text</li>
<li><p>There is around <code>80k</code> phrases to match. A phrase is a simple object:</p>
<pre><code>{
'phrase': 'phrase to match'
'link': 'link_url'
}
</code></pre></li>
<li><p>After finding all matches of phrases that exist in the text, the backend returns to the client what was matched - basically a map:</p>
<pre><code>range in text -> phrase
</code></pre></li>
</ul>
<p>Most is done. I'm about to tackle coding the phrase matching part. Everything else works smoothly. Since I don't want to reinvent the wheel I tried googling to find a Python library that does the job of efficiently finding phrases (from huge list) in text. However, I couldn't find anything.</p>
<p>I checked out the <a href="https://www.crummy.com/software/BeautifulSoup/" rel="noreferrer">BlueSoup</a> and <a href="https://www.nltk.org/" rel="noreferrer">Natural Language Toolkit</a>. However they don't seem to be doing what I'm looking for.</p>
<p>Do you guys know if there is a library that would be helpful in such task? Seems like a common thing to implement and I don't want to go custom if there is a well established library for that.</p>
| 0debug
|
is.na() counts a valid date as NA : <p>I created a datetime column from a character column like this:</p>
<pre><code>dat$created_datetime <- strptime(dat$created_at, format = '%d/%m/%Y %H:%M')
</code></pre>
<p>My cleanup code is reporting NAs in this column, but the entries look fine:</p>
<pre><code>> dat$created_datetime[514]
[1] "2016-10-02 02:26:00"
> is.na(dat$created_datetime[514])
[1] TRUE
> str(dat$created_datetime)
POSIXlt[1:300400], format: "2016-06-29 13:10:00" "2016-06-30 03:56:00" "2016-07-05 09:43:00" "2016-07-12 06:47:00" "2016-07-13 06:57:00" "2016-07-13 10:11:00" ...
</code></pre>
<p>Only 62 of 300k rows are affected. I can't figure out what's going on.</p>
| 0debug
|
How to generate every char all lower and upper conditions in a word?f : How to generate every char all lower and upper conditions in a word?f
eg: 'abc' => 'abc' 、'ABC'、'Abc'、'ABc'、'aBC'、'aBc'、'abC'、''...
eg : 'ab' => 'ab'、'AB'、'Ab'、'aB'
| 0debug
|
Can anyone provide some VBA code to loop through several regions of a worksheet? : I'm looking for some VBA that will allow me to loop through several different REGIONS on a worksheet. Not individual cells, necessarily, but to jump from "currentregion" to the next "currentregion". And once the region is located, it should be selected and copied.
I've tried setting a StartCell (via Cells.Find(What:="*") and then using that cell to select the corresponding 'currentregion'. The issue is how to move to the next 'currentregion', until all 'currentregions' on the worksheet have been copied/pasted.
My results are inconsistent so far, where sometimes all the necessary regions are copied/pasted, but other times some of the regions are ignored (same exact worksheet, same exact data).
| 0debug
|
for (var i = 0; i < count; i++) { } == for (var i = 0; i < count; i++) { }. What is this notation and why use it? : <p>Ran into the notation:</p>
<p><code>for (var i = 0; i &lt; count; i++) { }</code> </p>
<p>on <a href="https://blogs.unity3d.com/2015/12/23/1k-update-calls/" rel="nofollow noreferrer">this tutorial</a>. I gather it is equivalent to:</p>
<pre><code>for(var i = 0; i < count; i++) { }
</code></pre>
<p>What is this notation? Why use it? Does it perform better?</p>
| 0debug
|
Jenkins fails when running "service start jenkins" : <p>I installed jenkins on Cnetos 7 using the following:</p>
<pre><code>sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins
</code></pre>
<p>as <a href="http://pkg.jenkins-ci.org/redhat-stable/" rel="noreferrer">described on the official documentation</a></p>
<p>However when I run:</p>
<pre><code>service start jenkins
</code></pre>
<p>I get the following error message:</p>
<pre><code>Starting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
[FAILED]
</code></pre>
<p>Running <code>systemctl status jenkins.service</code> gives me this:</p>
<pre><code>● jenkins.service - LSB: Jenkins Continuous Integration Server
Loaded: loaded (/etc/rc.d/init.d/jenkins)
Active: failed (Result: exit-code) since Wed 2016-09-21 16:45:28 BST; 3min 59s ago
Docs: man:systemd-sysv-generator(8)
Process: 2818 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.of(JavaVMArguments...04)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.current(JavaVMArgu...92)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.all(Daemon.java:88)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: ... 6 more
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service: control process exited, code=exited s...s=1
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Failed to start LSB: Jenkins Continuous Integration Server.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Unit jenkins.service entered failed state.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service failed.
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: [FAILED]
Hint: Some lines were ellipsized, use -l to show in full.
</code></pre>
<p>and running <code>journalctl -xe</code> gives me this:</p>
<pre><code>Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.all(Daemon.java:88)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: ... 6 more
Sep 21 16:45:28 webstack.local.caplib runuser[2819]: pam_unix(runuser:session): session closed for user jenkin
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service: control process exited, code=exited status=
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Failed to start LSB: Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit jenkins.service has failed.
--
-- The result is failed.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Unit jenkins.service entered failed state.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service failed.
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: [FAILED]
Sep 21 16:45:28 webstack.local.caplib polkitd[1392]: Unregistered Authentication Agent for unix-process:2813:8
Sep 21 16:45:28 webstack.local.caplib dhclient[1390]: DHCPREQUEST on eno16777984 to 192.168.15.254 port 67 (xi
Sep 21 16:45:28 webstack.local.caplib dhclient[1390]: DHCPACK from 192.168.15.254 (xid=0x2ab6e6bc)
Sep 21 16:45:30 webstack.local.caplib dhclient[1390]: bound to 192.168.15.120 -- renewal in 865 seconds.
Sep 21 16:45:36 webstack.local.caplib systemd[1]: Starting Cleanup of Temporary Directories...
-- Subject: Unit systemd-tmpfiles-clean.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has begun starting up.
Sep 21 16:45:36 webstack.local.caplib systemd[1]: Started Cleanup of Temporary Directories.
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has finished starting up.
--
-- The start-up result is done.
</code></pre>
<p>Both of which is really unhelpful. How do I fix this issue?</p>
| 0debug
|
ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
void *value, size_t vsize)
{
ssize_t size = 0;
char buffer[PATH_MAX];
void *ovalue = value;
XattrOperations *xops;
char *orig_value, *orig_value_start;
ssize_t xattr_len, parsed_len = 0, attr_len;
xattr_len = llistxattr(rpath(ctx, path, buffer), value, 0);
if (xattr_len <= 0) {
return xattr_len;
}
orig_value = g_malloc(xattr_len);
xattr_len = llistxattr(rpath(ctx, path, buffer), orig_value, xattr_len);
orig_value_start = orig_value;
while (xattr_len > parsed_len) {
xops = get_xattr_operations(ctx->xops, orig_value);
if (!xops) {
goto next_entry;
}
if (!value) {
size += xops->listxattr(ctx, path, orig_value, value, vsize);
} else {
size = xops->listxattr(ctx, path, orig_value, value, vsize);
if (size < 0) {
goto err_out;
}
value += size;
vsize -= size;
}
next_entry:
attr_len = strlen(orig_value) + 1;
parsed_len += attr_len;
orig_value += attr_len;
}
if (value) {
size = value - ovalue;
}
err_out:
g_free(orig_value_start);
return size;
}
| 1threat
|
How to bind to attribute in Vue JS? : <p>I got this error</p>
<blockquote>
<p>Interpolation inside attributes has been removed. Use v-bind or the
colon shorthand instead. For example, instead of <code><div id="{{ val }}"></code>,
use <code><div :id="val"></code>.</p>
</blockquote>
<p>on this line</p>
<pre><code><a href="/Library/@Model.Username/{{myVueData.Id}}">
</code></pre>
<p>It works in Angular 1. How do you do it in Vue?</p>
| 0debug
|
IndexError: list index out of range How can i solve this and make it run? : <p><a href="https://i.stack.imgur.com/GdZnN.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>I am getting the IndexError: list index out of range </p>
| 0debug
|
AWS - SQS Batch Size and Lambda approach : <p>If I understand correctly, batch size setting on Lambda decides how many messages to take in one sweep from the SQS. Therefore this JSON (taken from the test Lambda SQS);</p>
<pre><code>{
"Records": [
{
"messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
"receiptHandle": "MessageReceiptHandle",
"body": "FAIL",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1523232000000",
"SenderId": "123456789012",
"ApproximateFirstReceiveTimestamp": "1523232000001"
},
"messageAttributes": {
},
"md5OfBody": "7b270e59b47ff90a553787216d55d91d",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:eu-west-1:123456789012:MyQueue",
"awsRegion": "eu-west-1"
}
]
}
</code></pre>
<p>There is Records array. And if I set batch size to 5, then if there are 5 messages in SQS, they will be included in array. If there are 10 messages, then Lambda will be invoked twice, with 5 messages in each Record.</p>
<p>I am now confused a bit, as to what approach to take. My Lambda is fairly simple. It will be Axios POST request to external service. If it errors out, I will throw an error. I could even use axios-retry, and make retries fairly easy.</p>
<p>Should I use batch in my case? Naively lookin, all I need is 1 to 1. In other words, message arrives. Lambda takes it. If it errors, it will be retried automatically a bit later.</p>
<p>Contrary, I would have to iterate via all messages and attempt an Axios request. What if the third of five messages fails, in that case I throw an error and Lambda is stopped. What happens to messages four and five? Are they resent to SQS and then again picked up for another execution?</p>
| 0debug
|
PHP: Split array values to key and value : <p>I have a txt file which contains:</p>
<pre><code>1:2
2:5
3:10
4:1
</code></pre>
<p>I need to be able to add to these numbers. For example I want to add to the last line +5:</p>
<pre><code>1:2
2:5
3:10
4:6
</code></pre>
<p>How can I achieve this? I was wondering if the right way was to input the file into an array but I have no idea how to do this as I need to separate the numbers into keys and values, I guess?</p>
| 0debug
|
static int cpu_gdb_write_register(CPUPPCState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
env->gpr[n] = ldtul_p(mem_buf);
return sizeof(target_ulong);
} else if (n < 64) {
if (gdb_has_xml)
return 0;
env->fpr[n-32] = ldfq_p(mem_buf);
return 8;
} else {
switch (n) {
case 64:
env->nip = ldtul_p(mem_buf);
return sizeof(target_ulong);
case 65:
ppc_store_msr(env, ldtul_p(mem_buf));
return sizeof(target_ulong);
case 66:
{
uint32_t cr = ldl_p(mem_buf);
int i;
for (i = 0; i < 8; i++)
env->crf[i] = (cr >> (32 - ((i + 1) * 4))) & 0xF;
return 4;
}
case 67:
env->lr = ldtul_p(mem_buf);
return sizeof(target_ulong);
case 68:
env->ctr = ldtul_p(mem_buf);
return sizeof(target_ulong);
case 69:
env->xer = ldtul_p(mem_buf);
return sizeof(target_ulong);
case 70:
if (gdb_has_xml)
return 0;
return 4;
}
}
return 0;
}
| 1threat
|
How to share group_vars between different inventories in Ansible? : <p>The Ansible best practices documentation <a href="http://docs.ansible.com/ansible/playbooks_best_practices.html#alternative-directory-layout" rel="noreferrer">recommends</a> to separate inventories:</p>
<pre>
inventories/
production/
hosts.ini # inventory file for production servers
group_vars/
group1 # here we assign variables to particular groups
group2 # ""
host_vars/
hostname1 # if systems need specific variables, put them here
hostname2 # ""
staging/
hosts.ini # inventory file for staging environment
group_vars/
group1 # here we assign variables to particular groups
group2 # ""
host_vars/
stagehost1 # if systems need specific variables, put them here
stagehost2 # ""
</pre>
<p>My staging and production environments are structured in the same way. I have in both environments the same groups. And it turns out that I have also the same group_vars for the same groups. This means redundancy I would like to wipe out.</p>
<p>Is there a way to share some group_vars between different inventories?</p>
<p>As a work-around I started to put shared group_vars into the roles.</p>
<pre><code>my_var:
my_group:
- { var1: 1, var2: 2 }
</code></pre>
<p>This makes it possible to iterate over some vars by intersecting the groups of a host with the defined var:</p>
<pre><code>with_items: "{{group_names | intersect(my_var.keys())}}"
</code></pre>
<p>But this is a bit complicate to understand and I think roles should not know anything about groups.</p>
<p>I would like to separate most of the inventories but share some of the group_vars in an easy to understand way. Is it possible to merge global group_vars with inventory specific group_vars?</p>
| 0debug
|
static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
{
VFIODevice *vdev = opaque;
uint64_t val = ((uint64_t)1 << (size * 8)) - 1;
if (unlikely(!vdev->rom)) {
memcpy(&val, vdev->rom + addr,
(addr < vdev->rom_size) ? MIN(size, vdev->rom_size - addr) : 0);
DPRINTF("%s(%04x:%02x:%02x.%x, 0x%"HWADDR_PRIx", 0x%x) = 0x%"PRIx64"\n",
__func__, vdev->host.domain, vdev->host.bus, vdev->host.slot,
vdev->host.function, addr, size, val);
return val;
| 1threat
|
static int net_client_init(const char *str)
{
const char *p;
char *q;
char device[64];
char buf[1024];
int vlan_id, ret;
VLANState *vlan;
p = str;
q = device;
while (*p != '\0' && *p != ',') {
if ((q - device) < sizeof(device) - 1)
*q++ = *p;
p++;
}
*q = '\0';
if (*p == ',')
p++;
vlan_id = 0;
if (get_param_value(buf, sizeof(buf), "vlan", p)) {
vlan_id = strtol(buf, NULL, 0);
}
vlan = qemu_find_vlan(vlan_id);
if (!vlan) {
fprintf(stderr, "Could not create vlan %d\n", vlan_id);
return -1;
}
if (!strcmp(device, "nic")) {
NICInfo *nd;
uint8_t *macaddr;
if (nb_nics >= MAX_NICS) {
fprintf(stderr, "Too Many NICs\n");
return -1;
}
nd = &nd_table[nb_nics];
macaddr = nd->macaddr;
macaddr[0] = 0x52;
macaddr[1] = 0x54;
macaddr[2] = 0x00;
macaddr[3] = 0x12;
macaddr[4] = 0x34;
macaddr[5] = 0x56 + nb_nics;
if (get_param_value(buf, sizeof(buf), "macaddr", p)) {
if (parse_macaddr(macaddr, buf) < 0) {
fprintf(stderr, "invalid syntax for ethernet address\n");
return -1;
}
}
if (get_param_value(buf, sizeof(buf), "model", p)) {
nd->model = strdup(buf);
}
nd->vlan = vlan;
nb_nics++;
vlan->nb_guest_devs++;
ret = 0;
} else
if (!strcmp(device, "none")) {
ret = 0;
} else
#ifdef CONFIG_SLIRP
if (!strcmp(device, "user")) {
if (get_param_value(buf, sizeof(buf), "hostname", p)) {
pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);
}
ret = net_slirp_init(vlan);
} else
#endif
#ifdef _WIN32
if (!strcmp(device, "tap")) {
char ifname[64];
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
fprintf(stderr, "tap: no interface name\n");
return -1;
}
ret = tap_win32_init(vlan, ifname);
} else
#else
if (!strcmp(device, "tap")) {
char ifname[64];
char setup_script[1024];
int fd;
if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
fd = strtol(buf, NULL, 0);
ret = -1;
if (net_tap_fd_init(vlan, fd))
ret = 0;
} else {
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
ifname[0] = '\0';
}
if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) {
pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);
}
ret = net_tap_init(vlan, ifname, setup_script);
}
} else
#endif
if (!strcmp(device, "socket")) {
if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
int fd;
fd = strtol(buf, NULL, 0);
ret = -1;
if (net_socket_fd_init(vlan, fd, 1))
ret = 0;
} else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) {
ret = net_socket_listen_init(vlan, buf);
} else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) {
ret = net_socket_connect_init(vlan, buf);
} else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) {
ret = net_socket_mcast_init(vlan, buf);
} else {
fprintf(stderr, "Unknown socket options: %s\n", p);
return -1;
}
} else
{
fprintf(stderr, "Unknown network device: %s\n", device);
return -1;
}
if (ret < 0) {
fprintf(stderr, "Could not initialize device '%s'\n", device);
}
return ret;
}
| 1threat
|
static void bswap_shdr(struct elf_shdr *shdr)
{
bswap32s(&shdr->sh_name);
bswap32s(&shdr->sh_type);
bswaptls(&shdr->sh_flags);
bswaptls(&shdr->sh_addr);
bswaptls(&shdr->sh_offset);
bswaptls(&shdr->sh_size);
bswap32s(&shdr->sh_link);
bswap32s(&shdr->sh_info);
bswaptls(&shdr->sh_addralign);
bswaptls(&shdr->sh_entsize);
}
| 1threat
|
ssize_t qemu_sendv_packet(VLANClientState *sender, const struct iovec *iov,
int iovcnt)
{
VLANState *vlan = sender->vlan;
VLANClientState *vc;
VLANPacket *packet;
ssize_t max_len = 0;
int i;
if (sender->link_down)
return calc_iov_length(iov, iovcnt);
if (vlan->delivering) {
max_len = calc_iov_length(iov, iovcnt);
packet = qemu_malloc(sizeof(VLANPacket) + max_len);
packet->next = vlan->send_queue;
packet->sender = sender;
packet->size = 0;
for (i = 0; i < iovcnt; i++) {
size_t len = iov[i].iov_len;
memcpy(packet->data + packet->size, iov[i].iov_base, len);
packet->size += len;
}
vlan->send_queue = packet;
} else {
vlan->delivering = 1;
for (vc = vlan->first_client; vc != NULL; vc = vc->next) {
ssize_t len = 0;
if (vc == sender) {
continue;
}
if (vc->link_down) {
len = calc_iov_length(iov, iovcnt);
} else if (vc->receive_iov) {
len = vc->receive_iov(vc->opaque, iov, iovcnt);
} else if (vc->receive) {
len = vc_sendv_compat(vc, iov, iovcnt);
}
max_len = MAX(max_len, len);
}
while ((packet = vlan->send_queue) != NULL) {
vlan->send_queue = packet->next;
qemu_deliver_packet(packet->sender, packet->data, packet->size);
qemu_free(packet);
}
vlan->delivering = 0;
}
return max_len;
}
| 1threat
|
OpenCV image Comparison And Similarity in Android : <p>I'm <code>OpenCV</code> learner. I was trying Image Comparison. I have used <strong>OpenCV 2.4.13.3</strong>
I have these two images <code>1.jpg</code> and <code>cam1.jpg</code>.</p>
<p><a href="https://i.stack.imgur.com/HkVgF.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/HkVgF.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/u4TgR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/u4TgR.jpg" alt="enter image description here"></a></p>
<p>When I use the following command in openCV</p>
<pre><code>File sdCard = Environment.getExternalStorageDirectory();
String path1, path2;
path1 = sdCard.getAbsolutePath() + "/1.jpg";
path2 = sdCard.getAbsolutePath() + "/cam1.jpg";
FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.BRIEF);
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
Mat img1 = Highgui.imread(path1);
Mat img2 = Highgui.imread(path2);
Mat descriptors1 = new Mat();
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
detector.detect(img1, keypoints1);
extractor.compute(img1, keypoints1, descriptors1);
//second image
// Mat img2 = Imgcodecs.imread(path2);
Mat descriptors2 = new Mat();
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
detector.detect(img2, keypoints2);
extractor.compute(img2, keypoints2, descriptors2);
//matcher image descriptors
MatOfDMatch matches = new MatOfDMatch();
matcher.match(descriptors1,descriptors2,matches);
// Filter matches by distance
MatOfDMatch filtered = filterMatchesByDistance(matches);
int total = (int) matches.size().height;
int Match= (int) filtered.size().height;
Log.d("LOG", "total:" + total + " Match:"+Match);
</code></pre>
<p><strong>Method filterMatchesByDistance</strong></p>
<pre><code> static MatOfDMatch filterMatchesByDistance(MatOfDMatch matches){
List<DMatch> matches_original = matches.toList();
List<DMatch> matches_filtered = new ArrayList<DMatch>();
int DIST_LIMIT = 30;
// Check all the matches distance and if it passes add to list of filtered matches
Log.d("DISTFILTER", "ORG SIZE:" + matches_original.size() + "");
for (int i = 0; i < matches_original.size(); i++) {
DMatch d = matches_original.get(i);
if (Math.abs(d.distance) <= DIST_LIMIT) {
matches_filtered.add(d);
}
}
Log.d("DISTFILTER", "FIL SIZE:" + matches_filtered.size() + "");
MatOfDMatch mat = new MatOfDMatch();
mat.fromList(matches_filtered);
return mat;
}
</code></pre>
<p><strong>Log</strong></p>
<pre><code>total:122 Match:30
</code></pre>
<p>As we can see from the log match is 30.<br>
But as we can see both images have same visual element (in).<br>
How can I get match=90 using openCV?<br>
It would be great if somebody can help with code snippet.<br>
If using opencv it is not possible then what are the other
alternatives we can look for?<br></p>
| 0debug
|
What restriction is perf_event_paranoid == 1 actually putting on x86 perf? : <p>Newer Linux kernels have a sysfs tunable <code>/proc/sys/kernel/perf_event_paranoid</code> which allows the user to adjust the available functionality of <code>perf_events</code> for non-root users, with higher numbers being more secure (offering correspondingly less functionality):</p>
<p>From the <a href="https://www.kernel.org/doc/Documentation/sysctl/kernel.txt" rel="noreferrer">kernel documenation</a> we have the following behavior for the various values:</p>
<blockquote>
<p>perf_event_paranoid:</p>
<p>Controls use of the performance events system by unprivileged users
(without CAP_SYS_ADMIN). The default value is 2.</p>
<p>-1: Allow use of (almost) all events by all users
Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK</p>
<p>>=0: Disallow ftrace function tracepoint by users without CAP_SYS_ADMIN
Disallow raw tracepoint access by users without CAP_SYS_ADMIN</p>
<p>>=1: Disallow CPU event access by users without CAP_SYS_ADMIN</p>
<p>>=2: Disallow kernel profiling by users without CAP_SYS_ADMIN</p>
</blockquote>
<p>I have <code>1</code> in my <code>perf_event_paranoid</code> file which should "Disallow CPU event access" - but what does that mean exactly?</p>
<p>A plain reading would imply no access to CPU performance counter events (such as Intel PMU events), but it seems I can access those just fine. For example:</p>
<pre><code>$ perf stat sleep 1
Performance counter stats for 'sleep 1':
0.408734 task-clock (msec) # 0.000 CPUs utilized
1 context-switches # 0.002 M/sec
0 cpu-migrations # 0.000 K/sec
57 page-faults # 0.139 M/sec
1,050,362 cycles # 2.570 GHz
769,135 instructions # 0.73 insn per cycle
152,661 branches # 373.497 M/sec
6,942 branch-misses # 4.55% of all branches
1.000830821 seconds time elapsed
</code></pre>
<p>Here, many of the events are CPU PMU events (<code>cycles</code>, <code>instructions</code>, <code>branches</code>, <code>branch-misses</code>, <code>cache-misses</code>).</p>
<p>If these aren't the CPU events being referred to, what are they?</p>
| 0debug
|
PHP password_hash changing every time : <p>I have the code</p>
<pre><code> echo password_hash( 'i=badatphp', PASSWORD_BCRYPT, [ 'cost' => 10 ] );
</code></pre>
<p>Every time I run the script the password changes</p>
<p>I'm using PHP 7, and in PHP 5 I used to be able to set a salt, but now I can't</p>
<p>How am I supposed to overcome not knowing what the salt is?</p>
| 0debug
|
Axios POST request fails with error status code 500: Internal Server error : <p>I'm trying to send a POST request locally with a username and password in the body through Axios. </p>
<p>I'm deploying a Flask app on <a href="http://127.0.0.1:5000/login" rel="noreferrer">http://127.0.0.1:5000/login</a>, which handles the /login route. The POST request fails with the following error</p>
<pre class="lang-js prettyprint-override"><code>POST http://127.0.0.1:5000/login 500 (INTERNAL SERVER ERROR)
Error: Request failed with status code 500
at createError (createError.js:16)
at settle (settle.js:18)
at XMLHttpRequest.handleLoad (xhr.js:77)
</code></pre>
<p>I researched a bit and thought it might be a problem with CORS, but this doesn't seem to be the case because I tried an Axios GET request and it worked fine (response logged properly). Here's part of my code</p>
<pre class="lang-js prettyprint-override"><code>axios.get("http://127.0.0.1:5000").then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
})
axios.post("http://127.0.0.1:5000/login", {
username: this.state.username,
password: this.state.password
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.log(error);
})
</code></pre>
<p>
Looking at Chrome DevTools, I can see that the POST request payload is properly populated. I then tried printing out the keys server-side in the Flask app using the following code, but I got nothing, empty. (which was expected since the POST request failed)</p>
<pre class="lang-js prettyprint-override"><code>dict = request.form
for key in dict:
print('form key '+dict[key])
</code></pre>
<p>HOWEVER using Postman with the corresponding keys and values works properly and returns a response and prints out the keys (see above). Where is the failure coming from? Why would the POST request fail when a GET seems to work just fine?</p>
| 0debug
|
function in array not working : I have array like
`binds= `["%ts%","%tm%","%per%"," <input value=\"gng(8,8)\"/> "];`
and I have function
function gng(a,b){
var c=a/b;
return c;
}
when I loop array for table column's inner text , I just see input box value equal gng(8,8) which is unwanted .Why it is not value equal 1
| 0debug
|
void show_pix_fmts(void)
{
list_fmts(avcodec_pix_fmt_string, PIX_FMT_NB);
}
| 1threat
|
Google Maps GMSMapView on custom UIView : <p>I want to display google maps on a view that's then added to <code>self.view</code>, rather than drawing the map directly on <code>self.view</code>. Therefore, I created a view in storyboard and changed its class to <code>GMSMapView</code>. I also created an outlet connection to that view called <code>gmView</code>. </p>
<p>I am using the following code that does unfortunately not show the map:</p>
<pre><code>let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: GMSCameraPosition.camera(withLatitude: 51.050657, longitude: 10.649514, zoom: 5.5))
gmView = mapView
</code></pre>
<p>Also, I tried adding the <code>mapView</code> to <code>self.view</code> as a subview, like this:</p>
<pre><code>self.view.addSubview(mapView)
</code></pre>
<p>...and inserting it:</p>
<pre><code>self.view.insertSubview(mapView, at: 0)
</code></pre>
<p>Note that I'm using Auto Layout if that changes anything.</p>
<p>None of these approaches seem to work for me.<br>
Any ideas?</p>
| 0debug
|
static void qdict_teardown(void)
{
QDECREF(tests_dict);
tests_dict = NULL;
}
| 1threat
|
alert('Hello ' + user_input);
| 1threat
|
vb.net login form cant connect to database : I have a problem in my login form everytime i want to login i receive message username or textbox invalid but in the database the username and password is correct
here is my code
Imports System.Data.SqlClient
Public Class LoginForm
Private Sub UsersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles UsersBindingNavigatorSaveItem.Click
Me.Validate()
Me.UsersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DataSet1)
End Sub
Private Sub LoginForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSet1.users' table. You can move, or remove it, as needed.
Me.UsersTableAdapter.Fill(Me.DataSet1.users)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim connection As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database_topdent.mdf;Integrated Security=True")
Dim command As New SqlCommand("Select * from users where User = @user and Password = @password ", connection)
command.Parameters.Add("@user", SqlDbType.VarChar).Value = UserTextBox.Text
command.Parameters.Add("@password", SqlDbType.VarChar).Value = PasswordTextBox.Text
Dim adapter As New SqlDataAdapter(command)
Dim table As New DataTable()
adapter.Fill(table)
If table.Rows.Count() <= 0 Then
MessageBox.Show("username or textbox invalid")
Else
MessageBox.Show("Login Succesful")
End If
End Sub
End Class
| 0debug
|
Merge Excel Rows with duplicate : <p>I have this table in Excel</p>
<p><a href="https://i.stack.imgur.com/SFUaU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SFUaU.png" alt="enter image description here"></a>
and I want to merge the row with the equal values of the 2 columns to obtain this table
<a href="https://i.stack.imgur.com/QH7J2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QH7J2.png" alt="enter image description here"></a> </p>
<p>I have no idea how to do: can you help me? I have read Excel tutorial but I have found only instruction about delete rows</p>
| 0debug
|
static void ptimer_reload(ptimer_state *s)
{
if (s->delta == 0) {
ptimer_trigger(s);
s->delta = s->limit;
}
if (s->delta == 0 || s->period == 0) {
fprintf(stderr, "Timer with period zero, disabling\n");
s->enabled = 0;
return;
}
s->last_event = s->next_event;
s->next_event = s->last_event + s->delta * s->period;
if (s->period_frac) {
s->next_event += ((int64_t)s->period_frac * s->delta) >> 32;
}
timer_mod(s->timer, s->next_event);
}
| 1threat
|
static int get_next_block(DumpState *s, RAMBlock *block)
{
while (1) {
block = QTAILQ_NEXT(block, next);
if (!block) {
return 1;
}
s->start = 0;
s->block = block;
if (s->has_filter) {
if (block->offset >= s->begin + s->length ||
block->offset + block->length <= s->begin) {
continue;
}
if (s->begin > block->offset) {
s->start = s->begin - block->offset;
}
}
return 0;
}
}
| 1threat
|
static CPUArchState *find_cpu(uint32_t thread_id)
{
CPUState *cpu;
cpu = qemu_get_cpu(thread_id);
if (cpu == NULL) {
return NULL;
}
return cpu->env_ptr;
}
| 1threat
|
Private getter and public setter for a Kotlin property : <p>How to make a property in Kotlin that has a private getter (or just do not have it) but has a public setter?</p>
<pre><code>var status
private get
</code></pre>
<p>doesn't work with an error: <code>Getter visibility must be the same as property visibility</code></p>
<p>In my case, the reason is for Java interop: I want my Java code to be able to call <code>setStatus</code> but not <code>getStatus</code>.</p>
| 0debug
|
Can't get the layout I want for Android App : The below layout gets put into a list view on a separate tab but I'm struggling with this view for my custom adapter.
The first imageView id 'icon' I want on the left. The textView id 'item' I want in the middle to the right of id icon and the textView 'textView1' I want underneath the item which is okay as this is fine even the text to the right of icon is fine.
The problem I am having is with the id pause and id icon2. I want these to the far right of the textviews and imageviews above.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="60dp"
android:layout_height="60dp"
android:padding="5dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="@+id/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:padding="2dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#4CBE99"
android:textAllCaps="true"
android:textStyle="bold"
/>
<ImageView
android:id="@+id/pause"
android:layout_gravity="left"
android:layout_width="35dp"
android:layout_height="35dp"
android:padding="5dp"
android:orientation="horizontal"
/>
<ImageView
android:id="@+id/icon2"
android:layout_gravity="right"
android:layout_width="35dp"
android:layout_height="35dp"
android:padding="5dp"
android:orientation="horizontal"
android:layout_toRightOf="@id/pause"
/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/adView"
android:layout_width="420dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible"
ads:adUnitId="ca-app-pub-3940256099942544/2793859312"
ads:adSize="200x80"
android:layout_weight="3.40"></com.google.android.gms.ads.NativeExpressAdView>
</LinearLayout>
</LinearLayout>
Please can someone help with this?
| 0debug
|
How to call a method from adapter in activity? : <p>I just want to call a method (which is declared in an adapter) from an activity . Is there any possible way to do it? </p>
| 0debug
|
static void ff_h264_idct8_add_mmx(uint8_t *dst, int16_t *block, int stride)
{
int i;
DECLARE_ALIGNED(8, int16_t, b2)[64];
block[0] += 32;
for(i=0; i<2; i++){
DECLARE_ALIGNED(8, uint64_t, tmp);
h264_idct8_1d(block+4*i);
__asm__ volatile(
"movq %%mm7, %0 \n\t"
TRANSPOSE4( %%mm0, %%mm2, %%mm4, %%mm6, %%mm7 )
"movq %%mm0, 8(%1) \n\t"
"movq %%mm6, 24(%1) \n\t"
"movq %%mm7, 40(%1) \n\t"
"movq %%mm4, 56(%1) \n\t"
"movq %0, %%mm7 \n\t"
TRANSPOSE4( %%mm7, %%mm5, %%mm3, %%mm1, %%mm0 )
"movq %%mm7, (%1) \n\t"
"movq %%mm1, 16(%1) \n\t"
"movq %%mm0, 32(%1) \n\t"
"movq %%mm3, 48(%1) \n\t"
: "=m"(tmp)
: "r"(b2+32*i)
: "memory"
);
}
for(i=0; i<2; i++){
h264_idct8_1d(b2+4*i);
__asm__ volatile(
"psraw $6, %%mm7 \n\t"
"psraw $6, %%mm6 \n\t"
"psraw $6, %%mm5 \n\t"
"psraw $6, %%mm4 \n\t"
"psraw $6, %%mm3 \n\t"
"psraw $6, %%mm2 \n\t"
"psraw $6, %%mm1 \n\t"
"psraw $6, %%mm0 \n\t"
"movq %%mm7, (%0) \n\t"
"movq %%mm5, 16(%0) \n\t"
"movq %%mm3, 32(%0) \n\t"
"movq %%mm1, 48(%0) \n\t"
"movq %%mm0, 64(%0) \n\t"
"movq %%mm2, 80(%0) \n\t"
"movq %%mm4, 96(%0) \n\t"
"movq %%mm6, 112(%0) \n\t"
:: "r"(b2+4*i)
: "memory"
);
}
ff_add_pixels_clamped_mmx(b2, dst, stride);
}
| 1threat
|
static int kvm_check_many_ioeventfds(void)
{
#if defined(CONFIG_EVENTFD) && defined(CONFIG_IOTHREAD)
int ioeventfds[7];
int i, ret = 0;
for (i = 0; i < ARRAY_SIZE(ioeventfds); i++) {
ioeventfds[i] = eventfd(0, EFD_CLOEXEC);
if (ioeventfds[i] < 0) {
break;
}
ret = kvm_set_ioeventfd_pio_word(ioeventfds[i], 0, i, true);
if (ret < 0) {
close(ioeventfds[i]);
break;
}
}
ret = i == ARRAY_SIZE(ioeventfds);
while (i-- > 0) {
kvm_set_ioeventfd_pio_word(ioeventfds[i], 0, i, false);
close(ioeventfds[i]);
}
return ret;
#else
return 0;
#endif
}
| 1threat
|
How to get a JSON String from JSONObject? : <p>I want to get a JSON String from the created JSONObject, which looks like a String when you want to create a JSONObject from that String.</p>
<p>I can write a method, I just cannot believe there isn't have a better solution.</p>
<pre><code>import org.json.JSONObject;
public class JSONString {
JSONObject jsonObject = new JSONObject();
jsonObject.append("symbol", "AAPL");
jsonObject.append("price", "211.17");
// this is the String what I want to get from the jsonObject variable
String wantedResultString = "{\n" +
" \"symbol\" : \"AAPL\",\n" +
" \"price\" : 211.17\n" +
"}";
}
</code></pre>
| 0debug
|
static int rndis_get_response(USBNetState *s, uint8_t *buf)
{
int ret = 0;
struct rndis_response *r = s->rndis_resp.tqh_first;
if (!r)
return ret;
TAILQ_REMOVE(&s->rndis_resp, r, entries);
ret = r->length;
memcpy(buf, r->buf, r->length);
qemu_free(r);
return ret;
}
| 1threat
|
How do you change the value of a variable in the parent class from the child class? : <p>How would i change the value of a value in the parent class using the child class? For example the parent class holds a int value of 4 and I want the child class to change that value to 8.</p>
| 0debug
|
void blk_eject(BlockBackend *blk, bool eject_flag)
{
BlockDriverState *bs = blk_bs(blk);
char *id;
assert(!blk->legacy_dev);
if (bs) {
bdrv_eject(bs, eject_flag);
id = blk_get_attached_dev_id(blk);
qapi_event_send_device_tray_moved(blk_name(blk), id,
eject_flag, &error_abort);
g_free(id);
}
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.