problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
How to split a string from a vector : <p>My homework is as follows:</p>
<p>Step Two - Create a file called connections.txt with a format like:</p>
<pre><code>Kelp-SeaUrchins
Kelp-SmallFishes
</code></pre>
<p>Read these names in from a file and split each string into two (org1,org2). Test your work just through printing for now. For example:</p>
<pre><code> cout << “pair = “ << org1 << “ , “ << org2 << endl;
</code></pre>
<p>I am not sure how to split the string, that is stored in a vector, using the hyphen as the token to split it. I was instructed to either create my own function, something like int ind(vector(string)orgs, string animal) { return index of animal in orgs.} or use the find function. </p>
| 0debug |
static int http_receive_data(HTTPContext *c)
{
int len;
HTTPContext *c1;
if (c->buffer_ptr >= c->buffer_end) {
FFStream *feed = c->stream;
if (c->data_count > FFM_PACKET_SIZE) {
lseek(c->feed_fd, feed->feed_write_index, SEEK_SET);
write(c->feed_fd, c->buffer, FFM_PACKET_SIZE);
feed->feed_write_index += FFM_PACKET_SIZE;
if (feed->feed_write_index > c->stream->feed_size)
feed->feed_size = feed->feed_write_index;
if (feed->feed_write_index >= c->stream->feed_max_size)
feed->feed_write_index = FFM_PACKET_SIZE;
ffm_write_write_index(c->feed_fd, feed->feed_write_index);
for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {
if (c1->state == HTTPSTATE_WAIT_FEED &&
c1->stream->feed == c->stream->feed) {
c1->state = HTTPSTATE_SEND_DATA;
}
}
} else {
AVFormatContext s;
ByteIOContext *pb = &s.pb;
int i;
memset(&s, 0, sizeof(s));
url_open_buf(pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY);
pb->buf_end = c->buffer_end;
pb->is_streamed = 1;
if (feed->fmt->read_header(&s, 0) < 0) {
goto fail;
}
if (s.nb_streams != feed->nb_streams) {
goto fail;
}
for (i = 0; i < s.nb_streams; i++) {
memcpy(&feed->streams[i]->codec, &s.streams[i]->codec, sizeof(AVCodecContext));
}
}
c->buffer_ptr = c->buffer;
}
len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);
if (len < 0) {
if (errno != EAGAIN && errno != EINTR) {
goto fail;
}
} else if (len == 0) {
goto fail;
} else {
c->buffer_ptr += len;
c->data_count += len;
}
return 0;
fail:
c->stream->feed_opened = 0;
close(c->feed_fd);
return -1;
}
| 1threat |
how to order by or Sort a int list and select nth element in C# : I have a list and I want to select the fifth highest element from list.
List<int> list = new List<int>();
list.Add(2);
list.Add(18);
list.Add(21);
list.Add(10);
list.Add(20);
list.Add(80);
list.Add(23);
list.Add(81);
list.Add(27);
list.Add(85);
OrderbyDescending is not worked for int list. Please suggest | 0debug |
Making firebase storage public for reading and writing on android : <p>I am new to firebase storage. Can anyone tell me how to make the storage files public for reading and writing?. The default code provided by firebase is given below. What changes should I make ?</p>
<pre><code>service firebase.storage {
match /b/image-view-b1cf5.appspot.com/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
</code></pre>
| 0debug |
Django Convert ID to slug : <p>Im new to django and wanted to <strong>convert id/pk to slug</strong>, I wanted to make <strong>url to be friendly or easy to understand</strong></p>
<p>Wanted to make url <code>http://127.0.0.1:8000/1/</code> to <code>http://127.0.0.1:8000/hello/</code></p>
<p>Model.py</p>
<pre><code>class Post(models.Model):
title=models.CharField(max_length=200)
description=models.TextField(max_length=10000)
pub_date=models.DateTimeField(auto_now_add=True)
comments=models.CharField(max_length=200, blank=True)
slug = models.SlugField(max_length=40, unique=True)
def __unicode__(self):
return self.title
def description_as_list(self):
return self.description.split('\n')
</code></pre>
<p>admin.py</p>
<pre><code>class PostAdmin(admin.ModelAdmin):
list_display=['title','description']
prepopulated_fields = {'slug': ('title',)}
class Meta:
model = Post
admin.site.register(Post,PostAdmin)
</code></pre>
<p>urls.py</p>
<pre><code>urlpatterns = [
url(r'^$', views.PostListView.as_view(),name='home'),
url(r'^(?P<slug>[\w-]+)/$', views.detail, name='detail'),
]
</code></pre>
<p>views.py</p>
<pre><code>class PostListView(ListView):
model = Post
template_name = 'blog_post.html'
queryset = Post.objects.order_by('-pub_date')
paginate_by = 2
def detail(request, id):
posts = Post.objects.get(id=id)
return render(request, "blog_detail.html", {'posts': posts,})
</code></pre>
<p>Templates</p>
<pre><code>{% for threads in object_list %}
<p class="blog-post-title"><a href="{% url 'detail' slug=threads.id %}">{{ threads.title }}</a></p>
<hr />
{% endfor %}
</code></pre>
<p>Following <strong>error</strong> is obtained by doing so...What more changes to be
<a href="https://i.stack.imgur.com/1Dh8g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Dh8g.png" alt="enter image description here"></a></p>
<p>Any help is appreciated to make url readable. Thanks in davance</p>
| 0debug |
How to properly make asynchronous / parallel database calls : <p>I'm looking for the proper way to handle multiple database calls that would likely benefit from running simultaneously. The queries are just to stored procedures that are either doing inserts or merges using data that is programmatically assembled into DataTables in my ASP.NET MVC app.</p>
<p>Of course I have seen some information on <code>async</code> and <code>await</code>, and that appears to be what I would need to do, but I don't have a clear understanding of how to implement it. Some information is saying that the calls would still be sequential, and that one would still be waiting on another to complete. That seems pointless.</p>
<p>Ultimately, I would like a solution that allows me to run all the queries in the time it takes for the longest procedure to complete. I would like all the queries to return the number of records affected (as they do now) as well.</p>
<p>Here is what I have going on now (which is in no way parallel):</p>
<pre><code>// Variable for number of records affected
var recordedStatistics = new Dictionary<string, int>();
// Connect to the database and run the update procedure
using (var dbc = new SqlConnection(db.Database.Connection.ConnectionString))
{
dbc.Open();
// Merge One procedure
using (SqlCommand cmd = new SqlCommand("MergeOneProcedure", dbc))
{
// 5 minute timeout on the query
cmd.CommandTimeout = 300;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TVP", MergeOneDataTable);
// Execute procedure and record the number of affected rows
recordedStatistics.Add("mergeOne", cmd.ExecuteNonQuery());
}
// Merge Two procedure
using (SqlCommand cmd = new SqlCommand("MergeTwoProcedure", dbc))
{
// 5 minute timeout on the query
cmd.CommandTimeout = 300;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TVP", MergeTwoDataTable);
// Execute procedure and record the number of affected rows
recordedStatistics.Add("mergeTwo", cmd.ExecuteNonQuery());
}
// Merge Three procedure
using (SqlCommand cmd = new SqlCommand("MergeThreeProcedure", dbc))
{
// 5 minute timeout on the query
cmd.CommandTimeout = 300;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TVP", MergeThreeDataTable);
// Execute procedure and record the number of affected rows
recordedStatistics.Add("mergeThree", cmd.ExecuteNonQuery());
}
// Merge Four procedure
using (SqlCommand cmd = new SqlCommand("MergeFourProcedure", dbc))
{
// 5 minute timeout on the query
cmd.CommandTimeout = 300;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TVP", MergeFourDataTable);
// Execute procedure and record the number of affected rows
recordedStatistics.Add("mergeFour", cmd.ExecuteNonQuery());
}
// Merge Five procedure
using (SqlCommand cmd = new SqlCommand("MergeFiveProcedure", dbc))
{
// 5 minute timeout on the query
cmd.CommandTimeout = 300;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TVP", MergeFiveDataTable);
// Execute procedure and record the number of affected rows
recordedStatistics.Add("mergeFive", cmd.ExecuteNonQuery());
}
dbc.Close();
}
return recordedStatistics;
</code></pre>
<p>All of that code is within the same method that assembles the data for the DataTables. My limited understanding of <code>async</code> would lead me to believe that I would need to extract the previous code into its own method. I would then call that method and <code>await</code> the return. However, I don't even know enough about it to begin.</p>
<p>I have never done any asynchronous/parallel/multithreaded coding before. This situation just makes me feel like it is the perfect time to jump in. That said, I would like to learn the best way, instead of having to unlearn the wrong way.</p>
| 0debug |
I have no idea why this error: "missing 1 required positional argument: 'self'" : <p>This is my code:</p>
<pre><code>
from tkinter import Tk, Button
import GUI
root = Tk()
b = GUI.time
button1 = Button(
root, text="Local time", command=b.local_time # text on top of button
) # button click event handler
button1.pack()
button2 = Button(
root, text="Greenwich time", command=b.greenwich_time # text on top of button
) # button click event handler
button2.pack()
root.mainloop()
</code></pre>
<p>And gets the b.local_time and b.greenwich_time from my class time:</p>
<pre><code>from time import strftime, localtime, gmtime
class time:
def __init__(self):
self.gm_time = strftime("Day: %d %b %Y\nTime: %H:%M:%S %p\n", gmtime())
self.l_time = strftime("Day: %d %b %Y\nTime: %H:%M:%S %p\n", localtime())
def greenwich_time(self):
print("Greenwich time:\n" + self.gm_time)
def local_time(self):
print("Local time:\n" + self.l_time)
</code></pre>
<p>But, when I click in the buttons, I get the errors:</p>
<pre><code>Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\carol\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
TypeError: local_time() missing 1 required positional argument: 'self'
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\carol\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
TypeError: greenwich_time() missing 1 required positional argument: 'self'
</code></pre>
<p>Someone could explain to me why is missing the required argument??
Thanks!!!</p>
| 0debug |
static void bdrv_delete(BlockDriverState *bs)
{
assert(!bs->dev);
assert(!bs->job);
assert(bdrv_op_blocker_is_empty(bs));
assert(!bs->refcnt);
assert(QLIST_EMPTY(&bs->dirty_bitmaps));
bdrv_close(bs);
bdrv_make_anon(bs);
g_free(bs);
} | 1threat |
static void gen_msgsnd(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_msgsnd(cpu_gpr[rB(ctx->opcode)]);
#endif
}
| 1threat |
void rgb16tobgr16(const uint8_t *src, uint8_t *dst, unsigned int src_size)
{
unsigned i;
unsigned num_pixels = src_size >> 1;
for(i=0; i<num_pixels; i++)
{
unsigned b,g,r;
register uint16_t rgb;
rgb = src[2*i];
r = rgb&0x1F;
g = (rgb&0x7E0)>>5;
b = (rgb&0xF800)>>11;
dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11);
}
}
| 1threat |
struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
unsigned long sdram_size,
const char *core)
{
int i;
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *)
g_malloc0(sizeof(struct omap_mpu_state_s));
qemu_irq dma_irqs[6];
DriveInfo *dinfo;
SysBusDevice *busdev;
if (!core)
core = "ti925t";
s->mpu_model = omap310;
s->cpu = cpu_arm_init(core);
if (s->cpu == NULL) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
s->sdram_size = sdram_size;
s->sram_size = OMAP15XX_SRAM_SIZE;
s->wakeup = qemu_allocate_irq(omap_mpu_wakeup, s, 0);
omap_clk_init(s);
memory_region_allocate_system_memory(&s->emiff_ram, NULL, "omap1.dram",
s->sdram_size);
memory_region_add_subregion(system_memory, OMAP_EMIFF_BASE, &s->emiff_ram);
memory_region_init_ram(&s->imif_ram, NULL, "omap1.sram", s->sram_size,
&error_abort);
vmstate_register_ram_global(&s->imif_ram);
memory_region_add_subregion(system_memory, OMAP_IMIF_BASE, &s->imif_ram);
omap_clkm_init(system_memory, 0xfffece00, 0xe1008000, s);
s->ih[0] = qdev_create(NULL, "omap-intc");
qdev_prop_set_uint32(s->ih[0], "size", 0x100);
qdev_prop_set_ptr(s->ih[0], "clk", omap_findclk(s, "arminth_ck"));
qdev_init_nofail(s->ih[0]);
busdev = SYS_BUS_DEVICE(s->ih[0]);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ));
sysbus_connect_irq(busdev, 1,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ));
sysbus_mmio_map(busdev, 0, 0xfffecb00);
s->ih[1] = qdev_create(NULL, "omap-intc");
qdev_prop_set_uint32(s->ih[1], "size", 0x800);
qdev_prop_set_ptr(s->ih[1], "clk", omap_findclk(s, "arminth_ck"));
qdev_init_nofail(s->ih[1]);
busdev = SYS_BUS_DEVICE(s->ih[1]);
sysbus_connect_irq(busdev, 0,
qdev_get_gpio_in(s->ih[0], OMAP_INT_15XX_IH2_IRQ));
sysbus_mmio_map(busdev, 0, 0xfffe0000);
for (i = 0; i < 6; i++) {
dma_irqs[i] = qdev_get_gpio_in(s->ih[omap1_dma_irq_map[i].ih],
omap1_dma_irq_map[i].intr);
}
s->dma = omap_dma_init(0xfffed800, dma_irqs, system_memory,
qdev_get_gpio_in(s->ih[0], OMAP_INT_DMA_LCD),
s, omap_findclk(s, "dma_ck"), omap_dma_3_1);
s->port[emiff ].addr_valid = omap_validate_emiff_addr;
s->port[emifs ].addr_valid = omap_validate_emifs_addr;
s->port[imif ].addr_valid = omap_validate_imif_addr;
s->port[tipb ].addr_valid = omap_validate_tipb_addr;
s->port[local ].addr_valid = omap_validate_local_addr;
s->port[tipb_mpui].addr_valid = omap_validate_tipb_mpui_addr;
soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->emiff_ram),
OMAP_EMIFF_BASE, s->sdram_size);
soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->imif_ram),
OMAP_IMIF_BASE, s->sram_size);
s->timer[0] = omap_mpu_timer_init(system_memory, 0xfffec500,
qdev_get_gpio_in(s->ih[0], OMAP_INT_TIMER1),
omap_findclk(s, "mputim_ck"));
s->timer[1] = omap_mpu_timer_init(system_memory, 0xfffec600,
qdev_get_gpio_in(s->ih[0], OMAP_INT_TIMER2),
omap_findclk(s, "mputim_ck"));
s->timer[2] = omap_mpu_timer_init(system_memory, 0xfffec700,
qdev_get_gpio_in(s->ih[0], OMAP_INT_TIMER3),
omap_findclk(s, "mputim_ck"));
s->wdt = omap_wd_timer_init(system_memory, 0xfffec800,
qdev_get_gpio_in(s->ih[0], OMAP_INT_WD_TIMER),
omap_findclk(s, "armwdt_ck"));
s->os_timer = omap_os_timer_init(system_memory, 0xfffb9000,
qdev_get_gpio_in(s->ih[1], OMAP_INT_OS_TIMER),
omap_findclk(s, "clk32-kHz"));
s->lcd = omap_lcdc_init(system_memory, 0xfffec000,
qdev_get_gpio_in(s->ih[0], OMAP_INT_LCD_CTRL),
omap_dma_get_lcdch(s->dma),
omap_findclk(s, "lcd_ck"));
omap_ulpd_pm_init(system_memory, 0xfffe0800, s);
omap_pin_cfg_init(system_memory, 0xfffe1000, s);
omap_id_init(system_memory, s);
omap_mpui_init(system_memory, 0xfffec900, s);
s->private_tipb = omap_tipb_bridge_init(system_memory, 0xfffeca00,
qdev_get_gpio_in(s->ih[0], OMAP_INT_BRIDGE_PRIV),
omap_findclk(s, "tipb_ck"));
s->public_tipb = omap_tipb_bridge_init(system_memory, 0xfffed300,
qdev_get_gpio_in(s->ih[0], OMAP_INT_BRIDGE_PUB),
omap_findclk(s, "tipb_ck"));
omap_tcmi_init(system_memory, 0xfffecc00, s);
s->uart[0] = omap_uart_init(0xfffb0000,
qdev_get_gpio_in(s->ih[1], OMAP_INT_UART1),
omap_findclk(s, "uart1_ck"),
omap_findclk(s, "uart1_ck"),
s->drq[OMAP_DMA_UART1_TX], s->drq[OMAP_DMA_UART1_RX],
"uart1",
serial_hds[0]);
s->uart[1] = omap_uart_init(0xfffb0800,
qdev_get_gpio_in(s->ih[1], OMAP_INT_UART2),
omap_findclk(s, "uart2_ck"),
omap_findclk(s, "uart2_ck"),
s->drq[OMAP_DMA_UART2_TX], s->drq[OMAP_DMA_UART2_RX],
"uart2",
serial_hds[0] ? serial_hds[1] : NULL);
s->uart[2] = omap_uart_init(0xfffb9800,
qdev_get_gpio_in(s->ih[0], OMAP_INT_UART3),
omap_findclk(s, "uart3_ck"),
omap_findclk(s, "uart3_ck"),
s->drq[OMAP_DMA_UART3_TX], s->drq[OMAP_DMA_UART3_RX],
"uart3",
serial_hds[0] && serial_hds[1] ? serial_hds[2] : NULL);
s->dpll[0] = omap_dpll_init(system_memory, 0xfffecf00,
omap_findclk(s, "dpll1"));
s->dpll[1] = omap_dpll_init(system_memory, 0xfffed000,
omap_findclk(s, "dpll2"));
s->dpll[2] = omap_dpll_init(system_memory, 0xfffed100,
omap_findclk(s, "dpll3"));
dinfo = drive_get(IF_SD, 0, 0);
if (!dinfo) {
fprintf(stderr, "qemu: missing SecureDigital device\n");
exit(1);
}
s->mmc = omap_mmc_init(0xfffb7800, system_memory,
blk_by_legacy_dinfo(dinfo),
qdev_get_gpio_in(s->ih[1], OMAP_INT_OQN),
&s->drq[OMAP_DMA_MMC_TX],
omap_findclk(s, "mmc_ck"));
s->mpuio = omap_mpuio_init(system_memory, 0xfffb5000,
qdev_get_gpio_in(s->ih[1], OMAP_INT_KEYBOARD),
qdev_get_gpio_in(s->ih[1], OMAP_INT_MPUIO),
s->wakeup, omap_findclk(s, "clk32-kHz"));
s->gpio = qdev_create(NULL, "omap-gpio");
qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model);
qdev_prop_set_ptr(s->gpio, "clk", omap_findclk(s, "arm_gpio_ck"));
qdev_init_nofail(s->gpio);
sysbus_connect_irq(SYS_BUS_DEVICE(s->gpio), 0,
qdev_get_gpio_in(s->ih[0], OMAP_INT_GPIO_BANK1));
sysbus_mmio_map(SYS_BUS_DEVICE(s->gpio), 0, 0xfffce000);
s->microwire = omap_uwire_init(system_memory, 0xfffb3000,
qdev_get_gpio_in(s->ih[1], OMAP_INT_uWireTX),
qdev_get_gpio_in(s->ih[1], OMAP_INT_uWireRX),
s->drq[OMAP_DMA_UWIRE_TX], omap_findclk(s, "mpuper_ck"));
s->pwl = omap_pwl_init(system_memory, 0xfffb5800,
omap_findclk(s, "armxor_ck"));
s->pwt = omap_pwt_init(system_memory, 0xfffb6000,
omap_findclk(s, "armxor_ck"));
s->i2c[0] = qdev_create(NULL, "omap_i2c");
qdev_prop_set_uint8(s->i2c[0], "revision", 0x11);
qdev_prop_set_ptr(s->i2c[0], "fclk", omap_findclk(s, "mpuper_ck"));
qdev_init_nofail(s->i2c[0]);
busdev = SYS_BUS_DEVICE(s->i2c[0]);
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(s->ih[1], OMAP_INT_I2C));
sysbus_connect_irq(busdev, 1, s->drq[OMAP_DMA_I2C_TX]);
sysbus_connect_irq(busdev, 2, s->drq[OMAP_DMA_I2C_RX]);
sysbus_mmio_map(busdev, 0, 0xfffb3800);
s->rtc = omap_rtc_init(system_memory, 0xfffb4800,
qdev_get_gpio_in(s->ih[1], OMAP_INT_RTC_TIMER),
qdev_get_gpio_in(s->ih[1], OMAP_INT_RTC_ALARM),
omap_findclk(s, "clk32-kHz"));
s->mcbsp1 = omap_mcbsp_init(system_memory, 0xfffb1800,
qdev_get_gpio_in(s->ih[1], OMAP_INT_McBSP1TX),
qdev_get_gpio_in(s->ih[1], OMAP_INT_McBSP1RX),
&s->drq[OMAP_DMA_MCBSP1_TX], omap_findclk(s, "dspxor_ck"));
s->mcbsp2 = omap_mcbsp_init(system_memory, 0xfffb1000,
qdev_get_gpio_in(s->ih[0],
OMAP_INT_310_McBSP2_TX),
qdev_get_gpio_in(s->ih[0],
OMAP_INT_310_McBSP2_RX),
&s->drq[OMAP_DMA_MCBSP2_TX], omap_findclk(s, "mpuper_ck"));
s->mcbsp3 = omap_mcbsp_init(system_memory, 0xfffb7000,
qdev_get_gpio_in(s->ih[1], OMAP_INT_McBSP3TX),
qdev_get_gpio_in(s->ih[1], OMAP_INT_McBSP3RX),
&s->drq[OMAP_DMA_MCBSP3_TX], omap_findclk(s, "dspxor_ck"));
s->led[0] = omap_lpg_init(system_memory,
0xfffbd000, omap_findclk(s, "clk32-kHz"));
s->led[1] = omap_lpg_init(system_memory,
0xfffbd800, omap_findclk(s, "clk32-kHz"));
omap_setup_dsp_mapping(system_memory, omap15xx_dsp_mm);
omap_setup_mpui_io(system_memory, s);
qemu_register_reset(omap1_mpu_reset, s);
return s;
}
| 1threat |
the transfer of the value in a fonction : public boolean judge(Parcelle p) {
int xx,yy;
int co;
for(int aa=0;aa<9;aa++) {
for(int bb=0;bb<5;bb++) {
if (p.equals(alist.get(aa).get(bb))) {
xx=aa;
yy=bb;
break;
}
}
}
co=alist.get(xx+1).get(yy).exist+alist.get(xx-1).get(yy-1).exist+alist.get(xx-1).get(yy).exist+alist.get(xx).get(yy-1).exist+alist.get(xx+1).get(yy+1).exist+alist.get(xx).get(yy+1).exist;
return co>=2;
}
alist is a 2-dimension arraylist of Pardelle.
and it alerts that I should initialize the int xx,yy,
but in the loop I've set the value of them.
So I don't know what the problem is.
| 0debug |
static bool is_zero_cluster(BlockDriverState *bs, int64_t start)
{
BDRVQcow2State *s = bs->opaque;
int nr;
BlockDriverState *file;
int64_t res = bdrv_get_block_status_above(bs, NULL, start,
s->cluster_sectors, &nr, &file);
return res >= 0 && ((res & BDRV_BLOCK_ZERO) || !(res & BDRV_BLOCK_DATA));
}
| 1threat |
static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
int n;
short *samples;
uint8_t *src;
samples = data;
src = buf;
if(buf_size > AVCODEC_MAX_AUDIO_FRAME_SIZE/2)
buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE/2;
switch(avctx->codec->id) {
case CODEC_ID_PCM_S32LE:
decode_to16(4, 1, 0, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_S32BE:
decode_to16(4, 0, 0, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_U32LE:
decode_to16(4, 1, 1, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_U32BE:
decode_to16(4, 0, 1, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_S24LE:
decode_to16(3, 1, 0, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_S24BE:
decode_to16(3, 0, 0, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_U24LE:
decode_to16(3, 1, 1, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_U24BE:
decode_to16(3, 0, 1, &src, &samples, buf_size);
break;
case CODEC_ID_PCM_S24DAUD:
n = buf_size / 3;
for(;n>0;n--) {
uint32_t v = src[0] << 16 | src[1] << 8 | src[2];
v >>= 4;
*samples++ = ff_reverse[(v >> 8) & 0xff] +
(ff_reverse[v & 0xff] << 8);
src += 3;
}
break;
case CODEC_ID_PCM_S16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = src[0] | (src[1] << 8);
src += 2;
}
break;
case CODEC_ID_PCM_S16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] << 8) | src[1];
src += 2;
}
break;
case CODEC_ID_PCM_U16LE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = (src[0] | (src[1] << 8)) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_U16BE:
n = buf_size >> 1;
for(;n>0;n--) {
*samples++ = ((src[0] << 8) | src[1]) - 0x8000;
src += 2;
}
break;
case CODEC_ID_PCM_S8:
n = buf_size;
for(;n>0;n--) {
*samples++ = src[0] << 8;
src++;
}
break;
case CODEC_ID_PCM_U8:
n = buf_size;
for(;n>0;n--) {
*samples++ = ((int)src[0] - 128) << 8;
src++;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
n = buf_size;
for(;n>0;n--) {
*samples++ = s->table[src[0]];
src++;
}
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
return src - buf;
}
| 1threat |
VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus)
{
VIOsPAPRDevice *sdev, *selected;
DeviceState *iter;
selected = NULL;
QTAILQ_FOREACH(iter, &bus->bus.children, sibling) {
if (qdev_get_info(iter) != &spapr_vty_info.qdev) {
continue;
}
sdev = DO_UPCAST(VIOsPAPRDevice, qdev, iter);
if (!selected) {
selected = sdev;
continue;
}
if (sdev->reg < selected->reg) {
selected = sdev;
}
}
return selected;
}
| 1threat |
alert('Hello ' + user_input); | 1threat |
Number function in javascript : number function in javascript can be used to multiply,divide,find remainder but cannot be used for subtraction and addition.
var theNumber = Number ( prompt (" Pick a number " , "") ) ;
alert (" difference " +
theNumber - theNumber ) ;
// -> difference NaN
why not 0?
var theNumber = Number ( prompt (" Pick a number " , "") ) ;
alert (" sum " +
theNumber + theNumber ) ;
// ->3
// ->33
why is concatenation occurring? why not 6?
please help!
| 0debug |
Art: Verification of X took Y ms : <p>I've got a warning in my logcat:</p>
<pre><code>W/art: Verification of void com.myapp.LoginFragment$override.lambda$logIn$5(com.myapp.LoginFragment, java.lang.Throwable) took 217.578ms
</code></pre>
<p>Here's the code:</p>
<pre><code>subscription = viewModel.logIn()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
this::showStudioSelection,
error -> {
ErrorResponse errorResponse = ErrorResponseFactory.create(error);
if (errorResponse.code() == ApiResult.BAD_REQUEST) {
Snackbar.make(getView(), R.string.login_bad_credentials, Snackbar.LENGTH_LONG)
.setAction(android.R.string.ok, v -> {})
.show();
} else {
Snackbar.make(getView(), "Unknown error " + errorResponse.code(), Snackbar.LENGTH_LONG)
.setAction(android.R.string.ok, v -> {})
.show();
}
viewModel.updateLoginButtonState();
}
);
</code></pre>
<p>220ms is quite a lot (and I feel like I'm noticing a lag on startup of that Fragment). </p>
<p>I'm using RxJava and retrolambda, but this is not the only spot where this message pops up so I don't think it's directly related.</p>
<p><strong>How can I influence the verification time?</strong> Is it even worth it?</p>
<p>It seems like it has something to do with cyclomatic complexity, since I could get rid of the waring by removing the <code>Snackbar.make</code> calls in the <code>if</code> with some more <em>dry</em> code:</p>
<pre><code>String errorMessage;
if (errorResponse.code() == ApiResult.BAD_REQUEST) {
errorMessage = getString(R.string.login_bad_credentials);
} else {
errorMessage = "Unknown error " + errorResponse.code();
}
</code></pre>
| 0debug |
Why am i getting an error on return sharePreferenceUtils : <p>I cant figure out why it wont let me return sharePreferenceUtils. is there a better way to do this? I get the error "incompatible types" </p>
<pre><code> private static String Preference_NAME = "CodeLotto";
private static SharePreferenceUtils sharePreferenceUtils;
private SharedPreferences sharedPreferences;
private SharePreferenceUtils(Context context){
Preference_NAME = Preference_NAME + context.getPackageName();
this.sharedPreferences = context.getSharedPreferences(Preference_NAME, Context.MODE_PRIVATE);
}
public static SharedPreferences getInstance(){
if (sharePreferenceUtils == null) {
sharePreferenceUtils = new SharePreferenceUtils(MyApp.getContext());
}
return sharePreferenceUtils;
}
public void saveString(String key, String Val){
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key, Val);
editor.commit();
}
public String getString(String key, String defVal){
return sharedPreferences.getString(key, defVal);
}
public String getString(String key){
return sharedPreferences.getString(key, "");
}
}
</code></pre>
| 0debug |
Load route from ios native code (objective c) : I'm integrating an ios native library. The library opens a third party app, this process data and reload my app using deep, the lib catches the response. I wanna load the JS screen component from the native ios code integrated.
I tried to use the `RCTLinkingManager` but I don't know how to get the application instance and options.
```objectivec
[RCTLinkingManager application:app openURL:url options:options];
```
Any knows how to?
| 0debug |
IIS Express not stopping when debug session ends : <p>All of a sudden IIS Express no longer stops when I stop debugging a web site in Visual Studio 2017.</p>
<p>I'm not sure when this behaviour started, but I have the following setup:</p>
<ul>
<li>Visual Studio 15.5.2 (Has been repaired)</li>
<li>IIS Express 10.0 x64 (Reinstalled)</li>
<li>An ASP.Net Core 2 project targeting <code>net461</code></li>
<li>I have disabled "Enable edit and continue" in Tools -> Options -> Debugging -> General</li>
</ul>
<p>Not sure when this started happedning, maybe when I updated to the lastest VS version. </p>
<p>What more can I try? </p>
| 0debug |
static void qbus_print(Monitor *mon, BusState *bus, int indent)
{
struct DeviceState *dev;
qdev_printf("bus: %s\n", bus->name);
indent += 2;
qdev_printf("type %s\n", bus_type_names[bus->type]);
LIST_FOREACH(dev, &bus->children, sibling) {
qdev_print(mon, dev, indent);
}
}
| 1threat |
Execute selection from script in Vim : <p>I'm trying to incorporate vim into my main workflow. A major sticking point for me has been interactively editing and running programs/scripts.</p>
<p>For example given that I'm currently vimmed into test.py</p>
<pre><code>print('hello')
x = 5
y = x+2
print(y)
</code></pre>
<p>Without leaving vim how would I:<br>
a) run the whole script without leaving vim<br>
b) run just "print('hello')"</p>
| 0debug |
static int default_fdset_dup_fd_remove(int dup_fd)
{
return -1;
}
| 1threat |
static int flic_probe(AVProbeData *p)
{
int magic_number;
if (p->buf_size < 6)
return 0;
magic_number = AV_RL16(&p->buf[4]);
if ((magic_number != FLIC_FILE_MAGIC_1) &&
(magic_number != FLIC_FILE_MAGIC_2) &&
(magic_number != FLIC_FILE_MAGIC_3))
return 0;
return AVPROBE_SCORE_MAX;
}
| 1threat |
static int openfile(char *name, int flags, int growable)
{
if (bs) {
fprintf(stderr, "file open already, try 'help close'\n");
return 1;
}
bs = bdrv_new("hda");
if (!bs)
return 1;
if (bdrv_open(bs, name, flags) == -1) {
fprintf(stderr, "%s: can't open device %s\n", progname, name);
bs = NULL;
return 1;
}
if (growable) {
if (!bs->drv || !bs->drv->protocol_name) {
fprintf(stderr,
"%s: only protocols can be opened growable\n",
progname);
return 1;
}
bs->growable = 1;
}
return 0;
}
| 1threat |
Manually restarting `ng build --watch` or `ng serve` : <p>When we use nodemon, for example, we can manually trigger a rebuild by typing <code>rs</code> to stdin and hitting return/enter.</p>
<p>I am wondering if there is a way to manually trigger a rebuild when using <code>ng build --watch</code> or <code>ng serve</code>. On occasion, these fail to pick up files, or fail during a bigger refactor. Instead of using ctrl-c, I am wondering if there is a way to type something into stdin.</p>
| 0debug |
Google maps work locally but not online. : <p>I cannot find out why Google Map works perfectly local but not online.
Check it: www.giacomobartoli.xyz at the end of the page.</p>
<p>Thanks in advance</p>
| 0debug |
static void gen_dmfc0 (CPUState *env, DisasContext *ctx, int reg, int sel)
{
const char *rn = "invalid";
if (sel != 0)
check_insn(env, ctx, ISA_MIPS64);
switch (reg) {
case 0:
switch (sel) {
case 0:
gen_op_mfc0_index();
rn = "Index";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpcontrol();
rn = "MVPControl";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpconf0();
rn = "MVPConf0";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_mfc0_mvpconf1();
rn = "MVPConf1";
break;
default:
goto die;
}
break;
case 1:
switch (sel) {
case 0:
gen_op_mfc0_random();
rn = "Random";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_vpecontrol();
rn = "VPEControl";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeconf0();
rn = "VPEConf0";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeconf1();
rn = "VPEConf1";
break;
case 4:
check_mips_mt(env, ctx);
gen_op_dmfc0_yqmask();
rn = "YQMask";
break;
case 5:
check_mips_mt(env, ctx);
gen_op_dmfc0_vpeschedule();
rn = "VPESchedule";
break;
case 6:
check_mips_mt(env, ctx);
gen_op_dmfc0_vpeschefback();
rn = "VPEScheFBack";
break;
case 7:
check_mips_mt(env, ctx);
gen_op_mfc0_vpeopt();
rn = "VPEOpt";
break;
default:
goto die;
}
break;
case 2:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo0();
rn = "EntryLo0";
break;
case 1:
check_mips_mt(env, ctx);
gen_op_mfc0_tcstatus();
rn = "TCStatus";
break;
case 2:
check_mips_mt(env, ctx);
gen_op_mfc0_tcbind();
rn = "TCBind";
break;
case 3:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcrestart();
rn = "TCRestart";
break;
case 4:
check_mips_mt(env, ctx);
gen_op_dmfc0_tchalt();
rn = "TCHalt";
break;
case 5:
check_mips_mt(env, ctx);
gen_op_dmfc0_tccontext();
rn = "TCContext";
break;
case 6:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcschedule();
rn = "TCSchedule";
break;
case 7:
check_mips_mt(env, ctx);
gen_op_dmfc0_tcschefback();
rn = "TCScheFBack";
break;
default:
goto die;
}
break;
case 3:
switch (sel) {
case 0:
gen_op_dmfc0_entrylo1();
rn = "EntryLo1";
break;
default:
goto die;
}
break;
case 4:
switch (sel) {
case 0:
gen_op_dmfc0_context();
rn = "Context";
break;
case 1:
rn = "ContextConfig";
default:
goto die;
}
break;
case 5:
switch (sel) {
case 0:
gen_op_mfc0_pagemask();
rn = "PageMask";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_pagegrain();
rn = "PageGrain";
break;
default:
goto die;
}
break;
case 6:
switch (sel) {
case 0:
gen_op_mfc0_wired();
rn = "Wired";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf0();
rn = "SRSConf0";
break;
case 2:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf1();
rn = "SRSConf1";
break;
case 3:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf2();
rn = "SRSConf2";
break;
case 4:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf3();
rn = "SRSConf3";
break;
case 5:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsconf4();
rn = "SRSConf4";
break;
default:
goto die;
}
break;
case 7:
switch (sel) {
case 0:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_hwrena();
rn = "HWREna";
break;
default:
goto die;
}
break;
case 8:
switch (sel) {
case 0:
gen_op_dmfc0_badvaddr();
rn = "BadVaddr";
break;
default:
goto die;
}
break;
case 9:
switch (sel) {
case 0:
gen_op_mfc0_count();
rn = "Count";
break;
default:
goto die;
}
break;
case 10:
switch (sel) {
case 0:
gen_op_dmfc0_entryhi();
rn = "EntryHi";
break;
default:
goto die;
}
break;
case 11:
switch (sel) {
case 0:
gen_op_mfc0_compare();
rn = "Compare";
break;
default:
goto die;
}
break;
case 12:
switch (sel) {
case 0:
gen_op_mfc0_status();
rn = "Status";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_intctl();
rn = "IntCtl";
break;
case 2:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsctl();
rn = "SRSCtl";
break;
case 3:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_srsmap();
rn = "SRSMap";
break;
default:
goto die;
}
break;
case 13:
switch (sel) {
case 0:
gen_op_mfc0_cause();
rn = "Cause";
break;
default:
goto die;
}
break;
case 14:
switch (sel) {
case 0:
gen_op_dmfc0_epc();
rn = "EPC";
break;
default:
goto die;
}
break;
case 15:
switch (sel) {
case 0:
gen_op_mfc0_prid();
rn = "PRid";
break;
case 1:
check_insn(env, ctx, ISA_MIPS32R2);
gen_op_mfc0_ebase();
rn = "EBase";
break;
default:
goto die;
}
break;
case 16:
switch (sel) {
case 0:
gen_op_mfc0_config0();
rn = "Config";
break;
case 1:
gen_op_mfc0_config1();
rn = "Config1";
break;
case 2:
gen_op_mfc0_config2();
rn = "Config2";
break;
case 3:
gen_op_mfc0_config3();
rn = "Config3";
break;
default:
goto die;
}
break;
case 17:
switch (sel) {
case 0:
gen_op_dmfc0_lladdr();
rn = "LLAddr";
break;
default:
goto die;
}
break;
case 18:
switch (sel) {
case 0 ... 7:
gen_op_dmfc0_watchlo(sel);
rn = "WatchLo";
break;
default:
goto die;
}
break;
case 19:
switch (sel) {
case 0 ... 7:
gen_op_mfc0_watchhi(sel);
rn = "WatchHi";
break;
default:
goto die;
}
break;
case 20:
switch (sel) {
case 0:
check_insn(env, ctx, ISA_MIPS3);
gen_op_dmfc0_xcontext();
rn = "XContext";
break;
default:
goto die;
}
break;
case 21:
switch (sel) {
case 0:
gen_op_mfc0_framemask();
rn = "Framemask";
break;
default:
goto die;
}
break;
case 22:
rn = "'Diagnostic";
break;
case 23:
switch (sel) {
case 0:
gen_op_mfc0_debug();
rn = "Debug";
break;
case 1:
rn = "TraceControl";
case 2:
rn = "TraceControl2";
case 3:
rn = "UserTraceData";
case 4:
rn = "TraceBPC";
default:
goto die;
}
break;
case 24:
switch (sel) {
case 0:
gen_op_dmfc0_depc();
rn = "DEPC";
break;
default:
goto die;
}
break;
case 25:
switch (sel) {
case 0:
gen_op_mfc0_performance0();
rn = "Performance0";
break;
case 1:
rn = "Performance1";
case 2:
rn = "Performance2";
case 3:
rn = "Performance3";
case 4:
rn = "Performance4";
case 5:
rn = "Performance5";
case 6:
rn = "Performance6";
case 7:
rn = "Performance7";
default:
goto die;
}
break;
case 26:
rn = "ECC";
break;
case 27:
switch (sel) {
case 0 ... 3:
rn = "CacheErr";
break;
default:
goto die;
}
break;
case 28:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taglo();
rn = "TagLo";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datalo();
rn = "DataLo";
break;
default:
goto die;
}
break;
case 29:
switch (sel) {
case 0:
case 2:
case 4:
case 6:
gen_op_mfc0_taghi();
rn = "TagHi";
break;
case 1:
case 3:
case 5:
case 7:
gen_op_mfc0_datahi();
rn = "DataHi";
break;
default:
goto die;
}
break;
case 30:
switch (sel) {
case 0:
gen_op_dmfc0_errorepc();
rn = "ErrorEPC";
break;
default:
goto die;
}
break;
case 31:
switch (sel) {
case 0:
gen_op_mfc0_desave();
rn = "DESAVE";
break;
default:
goto die;
}
break;
default:
goto die;
}
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
return;
die:
#if defined MIPS_DEBUG_DISAS
if (loglevel & CPU_LOG_TB_IN_ASM) {
fprintf(logfile, "dmfc0 %s (reg %d sel %d)\n",
rn, reg, sel);
}
#endif
generate_exception(ctx, EXCP_RI);
}
| 1threat |
C++ How to delete an array with an int ptr pointing to it : Hi so I have something like:
int *p=new int[3];
*p=1;
p++;
*p=2;
delete [] p;
Is this the correct way to delete the array that p is pointing to?
| 0debug |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
uint64_t nb_sectors;
uint8_t *outbuf;
int buflen;
switch (req->cmd.buf[0]) {
case INQUIRY:
case MODE_SENSE:
case MODE_SENSE_10:
case RESERVE:
case RESERVE_10:
case RELEASE:
case RELEASE_10:
case START_STOP:
case ALLOW_MEDIUM_REMOVAL:
case GET_CONFIGURATION:
case GET_EVENT_STATUS_NOTIFICATION:
case MECHANISM_STATUS:
case REQUEST_SENSE:
break;
default:
if (s->tray_open || !bdrv_is_inserted(s->qdev.conf.bs)) {
scsi_check_condition(r, SENSE_CODE(NO_MEDIUM));
return 0;
}
break;
}
if (req->cmd.xfer > 65536) {
goto illegal_request;
}
r->buflen = MAX(4096, req->cmd.xfer);
if (!r->iov.iov_base) {
r->iov.iov_base = qemu_blockalign(s->qdev.conf.bs, r->buflen);
}
buflen = req->cmd.xfer;
outbuf = r->iov.iov_base;
memset(outbuf, 0, r->buflen);
switch (req->cmd.buf[0]) {
case TEST_UNIT_READY:
assert(!s->tray_open && bdrv_is_inserted(s->qdev.conf.bs));
break;
case INQUIRY:
buflen = scsi_disk_emulate_inquiry(req, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case MODE_SENSE:
case MODE_SENSE_10:
buflen = scsi_disk_emulate_mode_sense(r, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case READ_TOC:
buflen = scsi_disk_emulate_read_toc(req, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case RESERVE:
if (req->cmd.buf[1] & 1) {
goto illegal_request;
}
break;
case RESERVE_10:
if (req->cmd.buf[1] & 3) {
goto illegal_request;
}
break;
case RELEASE:
if (req->cmd.buf[1] & 1) {
goto illegal_request;
}
break;
case RELEASE_10:
if (req->cmd.buf[1] & 3) {
goto illegal_request;
}
break;
case START_STOP:
if (scsi_disk_emulate_start_stop(r) < 0) {
return 0;
}
break;
case ALLOW_MEDIUM_REMOVAL:
s->tray_locked = req->cmd.buf[4] & 1;
bdrv_lock_medium(s->qdev.conf.bs, req->cmd.buf[4] & 1);
break;
case READ_CAPACITY_10:
memset(outbuf, 0, 8);
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!nb_sectors) {
scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY));
return 0;
}
if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) {
goto illegal_request;
}
nb_sectors /= s->qdev.blocksize / 512;
nb_sectors--;
s->qdev.max_lba = nb_sectors;
if (nb_sectors > UINT32_MAX) {
nb_sectors = UINT32_MAX;
}
outbuf[0] = (nb_sectors >> 24) & 0xff;
outbuf[1] = (nb_sectors >> 16) & 0xff;
outbuf[2] = (nb_sectors >> 8) & 0xff;
outbuf[3] = nb_sectors & 0xff;
outbuf[4] = 0;
outbuf[5] = 0;
outbuf[6] = s->qdev.blocksize >> 8;
outbuf[7] = 0;
break;
case REQUEST_SENSE:
buflen = scsi_build_sense(NULL, 0, outbuf, r->buflen,
(req->cmd.buf[1] & 1) == 0);
if (buflen < 0) {
goto illegal_request;
}
break;
case MECHANISM_STATUS:
buflen = scsi_emulate_mechanism_status(s, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case GET_CONFIGURATION:
buflen = scsi_get_configuration(s, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case GET_EVENT_STATUS_NOTIFICATION:
buflen = scsi_get_event_status_notification(s, r, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case READ_DISC_INFORMATION:
buflen = scsi_read_disc_information(s, r, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case READ_DVD_STRUCTURE:
buflen = scsi_read_dvd_structure(s, r, outbuf);
if (buflen < 0) {
goto illegal_request;
}
break;
case SERVICE_ACTION_IN_16:
if ((req->cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) {
DPRINTF("SAI READ CAPACITY(16)\n");
memset(outbuf, 0, req->cmd.xfer);
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
if (!nb_sectors) {
scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY));
return 0;
}
if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) {
goto illegal_request;
}
nb_sectors /= s->qdev.blocksize / 512;
nb_sectors--;
s->qdev.max_lba = nb_sectors;
outbuf[0] = (nb_sectors >> 56) & 0xff;
outbuf[1] = (nb_sectors >> 48) & 0xff;
outbuf[2] = (nb_sectors >> 40) & 0xff;
outbuf[3] = (nb_sectors >> 32) & 0xff;
outbuf[4] = (nb_sectors >> 24) & 0xff;
outbuf[5] = (nb_sectors >> 16) & 0xff;
outbuf[6] = (nb_sectors >> 8) & 0xff;
outbuf[7] = nb_sectors & 0xff;
outbuf[8] = 0;
outbuf[9] = 0;
outbuf[10] = s->qdev.blocksize >> 8;
outbuf[11] = 0;
outbuf[12] = 0;
outbuf[13] = get_physical_block_exp(&s->qdev.conf);
if (s->qdev.conf.discard_granularity) {
outbuf[14] = 0x80;
}
break;
}
DPRINTF("Unsupported Service Action In\n");
goto illegal_request;
case SYNCHRONIZE_CACHE:
scsi_req_ref(&r->req);
bdrv_acct_start(s->qdev.conf.bs, &r->acct, 0, BDRV_ACCT_FLUSH);
r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r);
return 0;
case SEEK_10:
DPRINTF("Seek(10) (sector %" PRId64 ")\n", r->req.cmd.lba);
if (r->req.cmd.lba > s->qdev.max_lba) {
goto illegal_lba;
}
break;
case MODE_SELECT:
DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer);
break;
case MODE_SELECT_10:
DPRINTF("Mode Select(10) (len %lu)\n", (long)r->req.cmd.xfer);
break;
case UNMAP:
DPRINTF("Unmap (len %lu)\n", (long)r->req.cmd.xfer);
break;
case WRITE_SAME_10:
case WRITE_SAME_16:
nb_sectors = scsi_data_cdb_length(r->req.cmd.buf);
if (bdrv_is_read_only(s->qdev.conf.bs)) {
scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
return 0;
}
if (!check_lba_range(s, r->req.cmd.lba, nb_sectors)) {
goto illegal_lba;
}
if (!(req->cmd.buf[1] & 0x8)) {
goto illegal_request;
}
scsi_req_ref(&r->req);
r->req.aiocb = bdrv_aio_discard(s->qdev.conf.bs,
r->req.cmd.lba * (s->qdev.blocksize / 512),
nb_sectors * (s->qdev.blocksize / 512),
scsi_aio_complete, r);
return 0;
default:
DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]);
scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE));
return 0;
}
assert(!r->req.aiocb);
r->iov.iov_len = MIN(r->buflen, req->cmd.xfer);
if (r->iov.iov_len == 0) {
scsi_req_complete(&r->req, GOOD);
}
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
assert(r->iov.iov_len == req->cmd.xfer);
return -r->iov.iov_len;
} else {
return r->iov.iov_len;
}
illegal_request:
if (r->req.status == -1) {
scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
}
return 0;
illegal_lba:
scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
return 0;
}
| 1threat |
lousy conversion from float to int.type checking in java : the Java is strong type checked language .the java book i am refer
> ***the complete java reference***< says that *numeric types such as integer and float are compatible with each other*
while typing the program i encountered a problem lousy conversion
package niit.program;
public class table5 {
public static void main(String args[]){
int i=5.6;
System.out.println(i);
}
}
[screenshot of the image ][1]
[1]: http://i.stack.imgur.com/2cAvn.png | 0debug |
how to continuously sync local data between iphone to iwatch when iPhone app in background mode ? : When iphone app is enter in background mode then ios automatically terminate app after 180 second. If we require to continuously data sync between iphone app to iwatch app. In this situation what can we do?
How to continuously data sync enable between iphone and iwatch when iphone app is in background and time was expired.
Lets see answer for more details. | 0debug |
Excel - writing a complex formula : i have a bunch of numbers and i want to write one formula in cell "AJ1" to reach the number "77" (see AJ2 in sample file)
Maybe it can be a VB macro to do is, i dont know...
[Sample File][1]
Thank you for your time & help.
[1]: https://drive.google.com/open?id=1783moPPd4cPElL0-dbmlXXUjZdDNk47N | 0debug |
Java file not showing in android studio : <p>I want to create a new application in android studio, when I open a new project I don't see a Java file like this.
the difference between my project and other project
<a href="https://imgur.com/a/HDSxYub" rel="nofollow noreferrer">https://imgur.com/a/HDSxYub</a></p>
| 0debug |
static size_t handle_aiocb_ioctl(struct qemu_paiocb *aiocb)
{
int ret;
ret = ioctl(aiocb->aio_fildes, aiocb->aio_ioctl_cmd, aiocb->aio_ioctl_buf);
if (ret == -1)
return -errno;
return aiocb->aio_nbytes;
}
| 1threat |
int scsi_build_sense(uint8_t *in_buf, int in_len,
uint8_t *buf, int len, bool fixed)
{
bool fixed_in;
SCSISense sense;
if (!fixed && len < 8) {
return 0;
}
if (in_len == 0) {
sense.key = NO_SENSE;
sense.asc = 0;
sense.ascq = 0;
} else {
fixed_in = (in_buf[0] & 2) == 0;
if (fixed == fixed_in) {
memcpy(buf, in_buf, MIN(len, in_len));
return MIN(len, in_len);
}
if (fixed_in) {
sense.key = in_buf[2];
sense.asc = in_buf[12];
sense.ascq = in_buf[13];
} else {
sense.key = in_buf[1];
sense.asc = in_buf[2];
sense.ascq = in_buf[3];
}
}
memset(buf, 0, len);
if (fixed) {
buf[0] = 0x70;
buf[2] = sense.key;
buf[7] = 10;
buf[12] = sense.asc;
buf[13] = sense.ascq;
return MIN(len, 18);
} else {
buf[0] = 0x72;
buf[1] = sense.key;
buf[2] = sense.asc;
buf[3] = sense.ascq;
return 8;
}
}
| 1threat |
even number for both value 1 and value 2 : i'm only getting random even number for value 1 . i need it for both value 1 and 2. Can anyone teach me how to solve it?
i'm using threadlocalrandom for it
public void setQuestion(){
Random rand = new Random();
int value1 = ThreadLocalRandom.current().nextInt(10,100);
int value2 = ThreadLocalRandom.current().nextInt(2,20);
int randomquestion = rand.nextInt(2);
if (randomquestion == 1){
question.setText("What is"+ value1 + "+" + value2 +" ? ");
expected= "" + (value1 + value2);
}else if (randomquestion == 2){
question.setText("What is"+value1 +"-" + value2 +" ? ");
expected="" + (value1 - value2);
}else if (randomquestion == 3){
question.setText("What is"+value1+ "*" + value2 +" ? ");
expected ="" + (value1*value2);
}else {
question.setText("What is"+value1+"/" + value2 +"?");
expected="" + (value1/value2);
}
sumanswer.setText("Total Score ="+ correctanswer +"Correct and"+ wronganswer + "Wrong");
}
i expect it can be in random even number for both value | 0debug |
int xics_alloc_block(XICSState *icp, int src, int num, bool lsi, bool align)
{
int i, first = -1;
ICSState *ics = &icp->ics[src];
assert(src == 0);
if (align) {
assert((num == 1) || (num == 2) || (num == 4) ||
(num == 8) || (num == 16) || (num == 32));
first = ics_find_free_block(ics, num, num);
} else {
first = ics_find_free_block(ics, num, 1);
}
if (first >= 0) {
for (i = first; i < first + num; ++i) {
ics_set_irq_type(ics, i, lsi);
}
}
first += ics->offset;
trace_xics_alloc_block(src, first, num, lsi, align);
return first;
}
| 1threat |
void *g_malloc0_n(size_t nmemb, size_t size)
{
size_t sz;
void *ptr;
__coverity_negative_sink__(nmemb);
__coverity_negative_sink__(size);
sz = nmemb * size;
ptr = __coverity_alloc__(size);
__coverity_writeall0__(ptr);
__coverity_mark_as_afm_allocated__(ptr, AFM_free);
return ptr;
}
| 1threat |
Find Text before a Tag : <p>I have a text in a XML File Link Below</p>
<pre><code><p>The artificial and industrial uses <xref>1989</xref> of microorganisms for material production have a long history of more than a thousand years. Recently, genetic operations have been widely applied to improve production. Two generally considered <xref>approaches, 2017</xref> introduce enzymes that have higher activities from other organisms or species and introduce enzymes to realize metabolic pathways that do not naturally occur in the microorganisms. The former method is popular because its operation is simpler and improvements are more predictable than <xref>(2001)</xref> with the latter method. <xref>2013</xref> Conventional gene modifications using ultraviolet or other radiation types are easy to achieve and have been widely applied in many industries. Nevertheless, the efficiency of such improvements is quite low because gene modifications occur accidentally and uncontrollably, and progress is made serendipitously. Therefore, gene introduction is currently used along with conventional methods.</p>
</code></pre>
<p>I need to get the text before all <code><xref></code> element in a <code><p></code> Element.</p>
<pre><code>var $element = $xml.find("p").addBack("p");
$element.each(function()
{
//code here
});
</code></pre>
<p>Output like</p>
<pre><code><p>The artificial and industrial <u>uses <xref>1989</xref></u> of microorganisms for material production have a long history of more than a thousand years. Recently, genetic operations have been widely applied to improve production. Two generally <u>considered <xref>approaches, 2017</xref></u> introduce enzymes that have higher activities from other organisms or species and introduce enzymes to realize metabolic pathways that do not naturally occur in the microorganisms. The former method is popular because its operation is simpler and improvements are more predictable <u>than <xref>(2001)</xref></u> with the latter <u>method. <xref>2013</xref></u> Conventional gene modifications using ultraviolet or other radiation types are easy to achieve and have been widely applied in many industries. Nevertheless, the efficiency of such improvements is quite low because gene modifications occur accidentally and uncontrollably, and progress is made serendipitously. Therefore, gene introduction is currently used along with conventional methods.</p>
</code></pre>
<p>I browse lot regards find text before element but i didnt get solution. please suggest solution thanks in advance</p>
| 0debug |
How to Create Store Procedure? : I have following fields i need TO create table in stored procedure i want set table name dbo.UploadFilesProject and Following Fields
@ProjectId (int, Input, No default)
@FileName (varchar(75), Input, No default)
@FilePath (varchar(500), Input, No default)
@UploadedDate (date, Input, No default)
@IsActive (bit, Input, No default)
@UpdatedBy (varchar(75), Input, No default)
@ClientId (int, Input, No default)
I am New Stored Procedure please anyone Tell me how to create stored Procedure ? thanks in advance | 0debug |
Why doesn't gcc resolve _mm256_loadu_pd as single vmovupd? : <p>I'm writing some <em>AVX</em> code and I need to load from potentially unaligned memory. I'm currently loading 4 <em>doubles</em>, hence I would use intrinsic instruction <a href="https://software.intel.com/en-us/node/524102" rel="noreferrer">_mm256_loadu_pd</a>; the code I've written is:</p>
<pre><code>__m256d d1 = _mm256_loadu_pd(vInOut + i*4);
</code></pre>
<p>I've then compiled with options <code>-O3 -mavx -g</code> and subsequently used <em>objdump</em> to get the assembler code plus annotated code and line (<code>objdump -S -M intel -l avx.obj</code>).<br>When I look into the underlying assembler code, I find the following:</p>
<pre><code>vmovupd xmm0,XMMWORD PTR [rsi+rax*1]
vinsertf128 ymm0,ymm0,XMMWORD PTR [rsi+rax*1+0x10],0x1
</code></pre>
<p>I was expecting to see this:</p>
<pre><code>vmovupd ymm0,XMMWORD PTR [rsi+rax*1]
</code></pre>
<p>and fully use the 256 bit register (<em>ymm0</em>), instead it looks like <em>gcc</em> has decided to fill in the 128 bit part (<em>xmm0</em>) and then load again the other half with <em>vinsertf128</em>.</p>
<p>Is someone able to explain this?<br>
Equivalent code is getting compiled with a single <em>vmovupd</em> in MSVC VS 2012.</p>
<p>I'm running <code>gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0</code> on <em>Ubuntu 18.04 x86-64</em>.</p>
| 0debug |
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
{
int ret;
dst->owner = src->owner;
ret = av_frame_ref(dst->f, src->f);
if (ret < 0)
return ret;
av_assert0(!dst->progress);
if (src->progress &&
!(dst->progress = av_buffer_ref(src->progress))) {
ff_thread_release_buffer(dst->owner, dst);
return AVERROR(ENOMEM);
}
return 0;
}
| 1threat |
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
{
enum AVCodecID codec_id;
unsigned v;
int len, tag;
int ret;
int object_type_id = avio_r8(pb);
avio_r8(pb);
avio_rb24(pb);
v = avio_rb32(pb);
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
if (v < INT32_MAX)
st->codec->rc_max_rate = v;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
st->codecpar->bit_rate = avio_rb32(pb);
codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
if (codec_id)
st->codecpar->codec_id = codec_id;
av_log(fc, AV_LOG_TRACE, "esds object type id 0x%02x\n", object_type_id);
len = ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecSpecificDescrTag) {
av_log(fc, AV_LOG_TRACE, "Specific MPEG-4 header len=%d\n", len);
if (!len || (uint64_t)len > (1<<30))
return -1;
av_free(st->codecpar->extradata);
if ((ret = ff_get_extradata(fc, st->codecpar, pb, len)) < 0)
return ret;
if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
MPEG4AudioConfig cfg = {0};
avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata,
st->codecpar->extradata_size * 8, 1);
st->codecpar->channels = cfg.channels;
if (cfg.object_type == 29 && cfg.sampling_index < 3)
st->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];
else if (cfg.ext_sample_rate)
st->codecpar->sample_rate = cfg.ext_sample_rate;
else
st->codecpar->sample_rate = cfg.sample_rate;
av_log(fc, AV_LOG_TRACE, "mp4a config channels %d obj %d ext obj %d "
"sample rate %d ext sample rate %d\n", st->codecpar->channels,
cfg.object_type, cfg.ext_object_type,
cfg.sample_rate, cfg.ext_sample_rate);
if (!(st->codecpar->codec_id = ff_codec_get_id(mp4_audio_types,
cfg.object_type)))
st->codecpar->codec_id = AV_CODEC_ID_AAC;
}
}
return 0;
}
| 1threat |
Find all HTML tags used on a webpage : <p>I need a list of all HTML-tags used on a specific page.</p>
<p>My goal is to get a list like this</p>
<pre><code><a>
<p>
<em>
<body>
</code></pre>
<p>and so on. I will then paste it into a text editor and remove duplicates and finally process the result in a Javascript.</p>
<p>How can I achieve this?</p>
| 0debug |
Using %i and %I symbol array literal : <p>Reading through a list of Rails questions, I'm having trouble finding what the %i does in relation to a symbol array. Does this mean anything to anyone?</p>
| 0debug |
android app button thats save the predefined contact to address book : <p>I need to add contact button in app, if user clicks on that a contact is stored in the user address book, with or without prompt.</p>
<pre><code>Name:- sharukh khan
website:- www.google.com
Phone:- 9999999999
Phone:- 8888888888
email:- s@p.com
skype:-
linkedin:-
etc
</code></pre>
<p>can anyone help?
thanks naina</p>
| 0debug |
int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
{
int rc;
struct timespec ts;
#if defined(__APPLE__) || defined(__NetBSD__)
compute_abs_deadline(&ts, ms);
pthread_mutex_lock(&sem->lock);
--sem->count;
while (sem->count < 0) {
rc = pthread_cond_timedwait(&sem->cond, &sem->lock, &ts);
if (rc == ETIMEDOUT) {
break;
}
if (rc != 0) {
error_exit(rc, __func__);
}
}
pthread_mutex_unlock(&sem->lock);
return (rc == ETIMEDOUT ? -1 : 0);
#else
if (ms <= 0) {
do {
rc = sem_trywait(&sem->sem);
} while (rc == -1 && errno == EINTR);
if (rc == -1 && errno == EAGAIN) {
return -1;
}
} else {
compute_abs_deadline(&ts, ms);
do {
rc = sem_timedwait(&sem->sem, &ts);
} while (rc == -1 && errno == EINTR);
if (rc == -1 && errno == ETIMEDOUT) {
return -1;
}
}
if (rc < 0) {
error_exit(errno, __func__);
}
return 0;
#endif
} | 1threat |
static void s390_pcihost_init_as(S390pciState *s)
{
int i;
S390PCIBusDevice *pbdev;
for (i = 0; i < PCI_SLOT_MAX; i++) {
pbdev = &s->pbdev[i];
memory_region_init(&pbdev->mr, OBJECT(s),
"iommu-root-s390", UINT64_MAX);
address_space_init(&pbdev->as, &pbdev->mr, "iommu-pci");
}
memory_region_init_io(&s->msix_notify_mr, OBJECT(s),
&s390_msi_ctrl_ops, s, "msix-s390", UINT64_MAX);
address_space_init(&s->msix_notify_as, &s->msix_notify_mr, "msix-pci");
}
| 1threat |
<bound method Response.json of <Response [200]>> : <p>I trying to make a request GET to <a href="https://randomuser.me/api/" rel="noreferrer">https://randomuser.me/api/</a></p>
<pre><code>import requests
import json
url = "https://randomuser.me/api/"
data = requests.get(url).json
print data
</code></pre>
<hr>
<p>I kept getting</p>
<pre><code># <bound method Response.json of <Response [200]>>
</code></pre>
<p>How do I see the json response ? Something like this </p>
<pre><code>{
"results": [
{
"user": {
"gender": "female",
"name": {
"title": "ms",
"first": "kerttu",
"last": "tervo"
},
"location": {
"street": "9102 aleksanterinkatu",
"city": "eurajoki",
"state": "pirkanmaa",
"zip": 67561
},
"email": "kerttu.tervo@example.com",
"username": "silvercat709",
"password": "papa",
"salt": "tOCPX2GL",
"md5": "86c60371eeb94596916d66cee898c869",
"sha1": "d06c4f2e43f8c0e53d88e538655f1152169ce575",
"sha256": "5a6b011841b27b08c38d2091dfb3d7ca50f55192ca0fcf6929dae098316c9aae",
"registered": 1419602511,
"dob": 1266822680,
"phone": "03-479-964",
"cell": "047-950-61-69",
"HETU": "220210A290R",
"picture": {
"large": "https://randomuser.me/api/portraits/women/68.jpg",
"medium": "https://randomuser.me/api/portraits/med/women/68.jpg",
"thumbnail": "https://randomuser.me/api/portraits/thumb/women/68.jpg"
}
}
}
],
"nationality": "FI",
"seed": "7d24284202c2cfdb06",
"version": "0.8"
}
</code></pre>
| 0debug |
static int xen_pt_word_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
uint16_t *val, uint16_t dev_value,
uint16_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
uint16_t writable_mask = 0;
uint16_t throughable_mask = get_throughable_mask(s, reg, valid_mask);
writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask;
cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask);
*val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask);
return 0;
}
| 1threat |
tune oracle sql query : i want to ask is it better to use Synonym or the actual name for the table to tune the performance of a sql query | 0debug |
int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
int start, int end, int fast_gain, int is_lfe,
int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
uint8_t *dba_lengths, uint8_t *dba_values,
int16_t *mask)
{
int16_t excite[AC3_CRITICAL_BANDS];
int band;
int band_start, band_end, begin, end1;
int lowcomp, fastleak, slowleak;
band_start = ff_ac3_bin_to_band_tab[start];
band_end = ff_ac3_bin_to_band_tab[end-1] + 1;
if (band_start == 0) {
lowcomp = 0;
lowcomp = calc_lowcomp1(lowcomp, band_psd[0], band_psd[1], 384);
excite[0] = band_psd[0] - fast_gain - lowcomp;
lowcomp = calc_lowcomp1(lowcomp, band_psd[1], band_psd[2], 384);
excite[1] = band_psd[1] - fast_gain - lowcomp;
begin = 7;
for (band = 2; band < 7; band++) {
if (!(is_lfe && band == 6))
lowcomp = calc_lowcomp1(lowcomp, band_psd[band], band_psd[band+1], 384);
fastleak = band_psd[band] - fast_gain;
slowleak = band_psd[band] - s->slow_gain;
excite[band] = fastleak - lowcomp;
if (!(is_lfe && band == 6)) {
if (band_psd[band] <= band_psd[band+1]) {
begin = band + 1;
break;
}
}
}
end1 = FFMIN(band_end, 22);
for (band = begin; band < end1; band++) {
if (!(is_lfe && band == 6))
lowcomp = calc_lowcomp(lowcomp, band_psd[band], band_psd[band+1], band);
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
excite[band] = FFMAX(fastleak - lowcomp, slowleak);
}
begin = 22;
} else {
begin = band_start;
fastleak = (s->cpl_fast_leak << 8) + 768;
slowleak = (s->cpl_slow_leak << 8) + 768;
}
for (band = begin; band < band_end; band++) {
fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
excite[band] = FFMAX(fastleak, slowleak);
}
for (band = band_start; band < band_end; band++) {
int tmp = s->db_per_bit - band_psd[band];
if (tmp > 0) {
excite[band] += tmp >> 2;
}
mask[band] = FFMAX(ff_ac3_hearing_threshold_tab[band >> s->sr_shift][s->sr_code], excite[band]);
}
if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
int i, seg, delta;
if (dba_nsegs > 8)
return -1;
band = band_start;
for (seg = 0; seg < dba_nsegs; seg++) {
band += dba_offsets[seg];
if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
return -1;
if (dba_values[seg] >= 4) {
delta = (dba_values[seg] - 3) * 128;
} else {
delta = (dba_values[seg] - 4) * 128;
}
for (i = 0; i < dba_lengths[seg]; i++) {
mask[band++] += delta;
}
}
}
return 0;
} | 1threat |
VBA Excel to Group data by Name : <p>I'm not sure if this is possible with VBA.</p>
<p>I have this Data not in group: <br>
<a href="https://i.stack.imgur.com/0YSpI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0YSpI.jpg" alt="Original Excel Table"></a></p>
<p>I need it to look like the following with "Module" grouped into Module 1,2,3, etc. and background color for the group: <br>
<a href="https://i.stack.imgur.com/sxuBl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sxuBl.jpg" alt="enter image description here"></a>
Please assist me with this in VBA. </p>
<p>Thank you very much!</p>
| 0debug |
SwiftUI adding custom UIViewControllerTransitioningDelegate : <p>I'm trying to create <code>SwiftUI</code> custom segue animation, like this </p>
<p><a href="https://i.stack.imgur.com/RLLSH.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/RLLSH.gif" alt="enter image description here"></a> </p>
<p>I try to chain the animation to <code>Destination</code> but no use, it just animates inside the contents of <code>Destination</code> after presentation animation finish.</p>
<pre><code>struct ContentView : View {
var body: some View {
NavigationView {
VStack {
List {
NavigationButton(destination: withAnimation{
Destination()
}.frame(width: 300, height: 300)
.animation(.basic())) {
CellView()
}
}
}
}
}
}
struct CellView : View {
var body: some View {
VStack {
Text("Cell")
}
}
}
struct Destination : View {
var body: some View {
VStack {
Text("GFD")
}
}
}
</code></pre>
| 0debug |
How to handle caching of JavaScript files imported as ES6 module : <h2>Old situation</h2>
<p>Previously, I used the following method to force the browser to reload my JavaScript file if there was a new version available.</p>
<pre><code><script src="common.js?version=1337"></script>
<script src="app.js?version=1337"></script>
</code></pre>
<p>My HTML is automatically generated (e.g. with PHP), so this is easy to automate.</p>
<h2>New situation</h2>
<p>Now I want to use ES6 modules and import my common code.
My HTML becomes:</p>
<pre><code><script src="app.js?version=1337" type="module"></script>
</code></pre>
<p>And <code>app.js</code> contains the import:</p>
<pre><code>import {foo, bar} from './common.js';
</code></pre>
<h2>Problem</h2>
<p>Now my question: how do I influence the caching of <code>common.js</code> in the new scenario?</p>
<p>I don't want to manually edit <code>app.js</code> every time I edit <code>common.js</code>. I also don't want to dynamically generate/pre-process any of my JavaScript files, if possible.</p>
| 0debug |
void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
void *opaque, QJSON *vmdesc)
{
VMStateField *field = vmsd->fields;
trace_vmstate_save_state_top(vmsd->name);
if (vmsd->pre_save) {
vmsd->pre_save(opaque);
}
if (vmdesc) {
json_prop_str(vmdesc, "vmsd_name", vmsd->name);
json_prop_int(vmdesc, "version", vmsd->version_id);
json_start_array(vmdesc, "fields");
}
while (field->name) {
if (!field->field_exists ||
field->field_exists(opaque, vmsd->version_id)) {
void *first_elem = opaque + field->offset;
int i, n_elems = vmstate_n_elems(opaque, field);
int size = vmstate_size(opaque, field);
int64_t old_offset, written_bytes;
QJSON *vmdesc_loop = vmdesc;
trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems);
if (field->flags & VMS_POINTER) {
first_elem = *(void **)first_elem;
assert(first_elem || !n_elems);
}
for (i = 0; i < n_elems; i++) {
void *curr_elem = first_elem + size * i;
vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems);
old_offset = qemu_ftell_fast(f);
if (field->flags & VMS_ARRAY_OF_POINTER) {
assert(curr_elem);
curr_elem = *(void **)curr_elem;
}
if (field->flags & VMS_STRUCT) {
vmstate_save_state(f, field->vmsd, curr_elem, vmdesc_loop);
} else {
field->info->put(f, curr_elem, size, field, vmdesc_loop);
}
written_bytes = qemu_ftell_fast(f) - old_offset;
vmsd_desc_field_end(vmsd, vmdesc_loop, field, written_bytes, i);
if (vmdesc_loop && vmsd_can_compress(field)) {
vmdesc_loop = NULL;
}
}
} else {
if (field->flags & VMS_MUST_EXIST) {
error_report("Output state validation failed: %s/%s",
vmsd->name, field->name);
assert(!(field->flags & VMS_MUST_EXIST));
}
}
field++;
}
if (vmdesc) {
json_end_array(vmdesc);
}
vmstate_subsection_save(f, vmsd, opaque, vmdesc);
}
| 1threat |
jquery $(this).data selecter : **view**
echo '<div class="carousel-inner">';
echo '<div class="item active">';
echo'<h4>' . $vid->VIDEO_NAME . '</h4>';
echo'<input type="text" class="" data-primary="' . $vid->ID . '" value="' . $vid->ID . '">';
echo '<video width="500" height="281" controls>';
echo '<source src="' . base_url() . $vid->VIDEO_URL . '" type="video/mp4">';
echo 'Your browser does not support the video tag.';
echo '</video>';
echo '</div>';
echo '</div>';
echo '</div>';
**script**
//rate videos start
$('[value="bad"]').click(function (e) {
console.log($(this));
lert($(this).data("primary"));
});
I'm try to get the ID of each video element but results comes as undefined. Any help there?????
| 0debug |
Install libc++ on ubuntu : <p>I am wondering what is the right/easy way to install a binary libc++ on Ubuntu, in my case Trusty aka 14.04?</p>
<p>On the LLVM web site there are apt packages <a href="http://apt.llvm.org/" rel="noreferrer">http://apt.llvm.org/</a> and I have used these to install 3.9. However these packages don't seem to include libc++. I install the libc++-dev package but that seems to be a really old version. There are also binaries that can be downloaded <a href="http://llvm.org/releases/download.html#3.9.0" rel="noreferrer">http://llvm.org/releases/download.html#3.9.0</a>. These do seem to contain libc++ but I'm not sure if I can just copy bits of this into places like /usr/include/c++/v1, in fact I'm not really sure what bits I would need to copy. I am aware I can use libc++ from an alternate location as documented here <a href="http://libcxx.llvm.org/docs/UsingLibcxx.html" rel="noreferrer">http://libcxx.llvm.org/docs/UsingLibcxx.html</a> which I have tried. However I can't modify the build system of the large code base I work on to do this.</p>
<p>So is three any reason the apt packages don't include libc++ and any pointers to installing a binary would be gratefully recieved.</p>
| 0debug |
iscsi_connect_cb(struct iscsi_context *iscsi, int status, void *command_data,
void *opaque)
{
struct IscsiTask *itask = opaque;
struct scsi_task *task;
if (status != 0) {
itask->status = 1;
itask->complete = 1;
return;
}
task = iscsi_inquiry_task(iscsi, itask->iscsilun->lun,
0, 0, 36,
iscsi_inquiry_cb, opaque);
if (task == NULL) {
error_report("iSCSI: failed to send inquiry command.");
itask->status = 1;
itask->complete = 1;
return;
}
}
| 1threat |
Center UIView vertically in scroll view when its dynamic Labels are small enough, but align it to the top once they are not : <p>I have a view with 3 dynamic labels inside it and I am trying to find a way to centre it vertically in a scroll view but when its dynamic labels are too large to fit on a page, make the text start from the top. What Xcode is doing at the moment is this:</p>
<p><a href="https://i.stack.imgur.com/oFVN0.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/oFVN0.jpg" alt="enter image description here"></a></p>
<p>What I am trying to do is this:</p>
<p><a href="https://i.stack.imgur.com/Y6zjH.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Y6zjH.jpg" alt="enter image description here"></a></p>
<p>Any ideas about how to achieve this?
Thanks.</p>
| 0debug |
rotating two lines around an origin in python : I have two lines which meet around origin z and y, listed below. When I plot these according to certain functions I get the attached plot.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
origin_z = 260
origin_y = 244
plt.plot(phi_z+origin_z,phi_y+origin_y,'b')
plt.plot(phi_z+origin_z,phi_y+origin_y,'r')
<!-- end snippet -->
Where phi_z and _y are some functions (which I have avoided posting for the sake of clarity). I want to rotate both lines about 45 degrees clockwise around the specified origin [image of lines][1], but when I try the following code, it merely shifts the lines further along each axis rather than rotating them:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
phi_z_rot = origin_z + np.cos(45) * (phi_z - origin_z) - np.sin(45) * (phi_z - origin_z)
phi_y_rot = origin_y + np.cos(45) * (phi_y - origin_y) - np.sin(45) * (phi_y - origin_y)
<!-- end snippet -->
Can anyone tell me what I'm doing wrong? Sorry for not posting more of the functions, but hopefully it isn't necessary.
[1]: https://i.stack.imgur.com/misJP.png | 0debug |
Powershell - switch - multiple variables : I'm trying to create a script which will work assign different IP ranges depending on the choice, currently I've done something like this:
# Get DHCP Scope Start - first IP to check - End Last IP to check
$X = 0
$Y = 0
$Z = 0
$End = 0
$DHCPServer = "DHCP"
$ScopeID = "10.0.0.0"
switch (Read-Host "Choose device to add: 1 PS3,2 PS4,3 PS4Pro,4 XboxOne,") {
1 {$z = 1 $End = 20}
2 {$z = 30 $End = 50}
3 {$z = 100 $End = 255}
4 {$y = 1 $z = 1 $end = 100}
}
But no matter how I type arguments, Powershell always return the errors like "Unexpected token $end in expression or statement
Is there a way to fix it? | 0debug |
why else if not working here ? : > When i will getIntent name for particular place my map will focus on that place
but its working for only one place why is it so ? here is my code
if(restaurant_name != null ) {
if (restaurant_name.equals("Fun N Food")) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(26.89209, 75.82759), 15.0f));
mMap.addMarker(new MarkerOptions()
.position(new LatLng(26.89209, 75.82759))
.title("FUN N FOOD"))
.showInfoWindow();
}
else
if (restaurant_name.equals("Hoagies")) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(26.89515, 75.83052), 15.0f));
mMap.addMarker(new MarkerOptions()
.position(new LatLng(26.89515, 75.83052))
.title("HOAGIES"))
.showInfoWindow();
}
else
if (restaurant_name.equals("Ping Pang")) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(26.89568, 75.83060), 15.0f));
mMap.addMarker(new MarkerOptions()
.position(new LatLng(26.89568, 75.83060))
.title("PING PANG"))
.showInfoWindow();
}
> Here only Fun n Food is working .. why all other two is not working what am doing wrong ? i try switch case also but in that non of one is working plz help me | 0debug |
Is it possible to animate attribute change using jQuery? : <p>I need to change the "src" attribute of an "img" element after hovering over its parent element.</p>
<p>I have this HTML:</p>
<pre><code><div class="thumbnail">
<img src="img/1_thumb.jpg">
</div>
</code></pre>
<p>And I need to change the src value from "img/1_thumb.jpg" to "img/1_thumb_hov.jpg"</p>
<p>I did it with this jQuery code</p>
<pre><code>$('.thumbnail').hover(function() {
$(this).children(0).attr('src', 'img/1_thumbnail_hov.jpg');
}, function() {
$(this).children(0).attr('src', 'img/1_thumbnail.jpg');
});
</code></pre>
<p>But as you can tell, this will only do a fast change and I'd like to make it fade if possible.</p>
<p>Thank you so much, if you can help me solve this.</p>
| 0debug |
static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max)
{
int sb, j, k, n, ch, run, channels;
int joined_stereo, zero_encoding, chs;
int type34_first;
float type34_div = 0;
float type34_predictor;
float samples[10], sign_bits[16];
if (length == 0) {
for (sb=sb_min; sb < sb_max; sb++)
build_sb_samples_from_noise (q, sb);
return;
}
for (sb = sb_min; sb < sb_max; sb++) {
FIX_NOISE_IDX(q->noise_idx);
channels = q->nb_channels;
if (q->nb_channels <= 1 || sb < 12)
joined_stereo = 0;
else if (sb >= 24)
joined_stereo = 1;
else
joined_stereo = (get_bits_left(gb) >= 1) ? get_bits1 (gb) : 0;
if (joined_stereo) {
if (get_bits_left(gb) >= 16)
for (j = 0; j < 16; j++)
sign_bits[j] = get_bits1 (gb);
for (j = 0; j < 64; j++)
if (q->coding_method[1][sb][j] > q->coding_method[0][sb][j])
q->coding_method[0][sb][j] = q->coding_method[1][sb][j];
fix_coding_method_array(sb, q->nb_channels, q->coding_method);
channels = 1;
}
for (ch = 0; ch < channels; ch++) {
zero_encoding = (get_bits_left(gb) >= 1) ? get_bits1(gb) : 0;
type34_predictor = 0.0;
type34_first = 1;
for (j = 0; j < 128; ) {
switch (q->coding_method[ch][sb][j / 2]) {
case 8:
if (get_bits_left(gb) >= 10) {
if (zero_encoding) {
for (k = 0; k < 5; k++) {
if ((j + 2 * k) >= 128)
break;
samples[2 * k] = get_bits1(gb) ? dequant_1bit[joined_stereo][2 * get_bits1(gb)] : 0;
}
} else {
n = get_bits(gb, 8);
for (k = 0; k < 5; k++)
samples[2 * k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]];
}
for (k = 0; k < 5; k++)
samples[2 * k + 1] = SB_DITHERING_NOISE(sb,q->noise_idx);
} else {
for (k = 0; k < 10; k++)
samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx);
}
run = 10;
break;
case 10:
if (get_bits_left(gb) >= 1) {
float f = 0.81;
if (get_bits1(gb))
f = -f;
f -= noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0;
samples[0] = f;
} else {
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
}
run = 1;
break;
case 16:
if (get_bits_left(gb) >= 10) {
if (zero_encoding) {
for (k = 0; k < 5; k++) {
if ((j + k) >= 128)
break;
samples[k] = (get_bits1(gb) == 0) ? 0 : dequant_1bit[joined_stereo][2 * get_bits1(gb)];
}
} else {
n = get_bits (gb, 8);
for (k = 0; k < 5; k++)
samples[k] = dequant_1bit[joined_stereo][random_dequant_index[n][k]];
}
} else {
for (k = 0; k < 5; k++)
samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx);
}
run = 5;
break;
case 24:
if (get_bits_left(gb) >= 7) {
n = get_bits(gb, 7);
for (k = 0; k < 3; k++)
samples[k] = (random_dequant_type24[n][k] - 2.0) * 0.5;
} else {
for (k = 0; k < 3; k++)
samples[k] = SB_DITHERING_NOISE(sb,q->noise_idx);
}
run = 3;
break;
case 30:
if (get_bits_left(gb) >= 4)
samples[0] = type30_dequant[qdm2_get_vlc(gb, &vlc_tab_type30, 0, 1)];
else
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
run = 1;
break;
case 34:
if (get_bits_left(gb) >= 7) {
if (type34_first) {
type34_div = (float)(1 << get_bits(gb, 2));
samples[0] = ((float)get_bits(gb, 5) - 16.0) / 15.0;
type34_predictor = samples[0];
type34_first = 0;
} else {
samples[0] = type34_delta[qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1)] / type34_div + type34_predictor;
type34_predictor = samples[0];
}
} else {
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
}
run = 1;
break;
default:
samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
run = 1;
break;
}
if (joined_stereo) {
float tmp[10][MPA_MAX_CHANNELS];
for (k = 0; k < run; k++) {
tmp[k][0] = samples[k];
tmp[k][1] = (sign_bits[(j + k) / 8]) ? -samples[k] : samples[k];
}
for (chs = 0; chs < q->nb_channels; chs++)
for (k = 0; k < run; k++)
if ((j + k) < 128)
q->sb_samples[chs][j + k][sb] = q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs];
} else {
for (k = 0; k < run; k++)
if ((j + k) < 128)
q->sb_samples[ch][j + k][sb] = q->tone_level[ch][sb][(j + k)/2] * samples[k];
}
j += run;
}
}
}
}
| 1threat |
void virtio_save(VirtIODevice *vdev, QEMUFile *f)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t guest_features_lo = (vdev->guest_features & 0xffffffff);
int i;
if (k->save_config) {
k->save_config(qbus->parent, f);
}
qemu_put_8s(f, &vdev->status);
qemu_put_8s(f, &vdev->isr);
qemu_put_be16s(f, &vdev->queue_sel);
qemu_put_be32s(f, &guest_features_lo);
qemu_put_be32(f, vdev->config_len);
qemu_put_buffer(f, vdev->config, vdev->config_len);
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
if (vdev->vq[i].vring.num == 0)
break;
}
qemu_put_be32(f, i);
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
if (vdev->vq[i].vring.num == 0)
break;
qemu_put_be32(f, vdev->vq[i].vring.num);
if (k->has_variable_vring_alignment) {
qemu_put_be32(f, vdev->vq[i].vring.align);
}
qemu_put_be64(f, vdev->vq[i].vring.desc);
qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
if (k->save_queue) {
k->save_queue(qbus->parent, i, f);
}
}
if (vdc->save != NULL) {
vdc->save(vdev, f);
}
if (vdc->vmsd) {
vmstate_save_state(f, vdc->vmsd, vdev, NULL);
}
vmstate_save_state(f, &vmstate_virtio, vdev, NULL);
}
| 1threat |
static gboolean fd_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
FDCharDriver *s = chr->opaque;
int len;
uint8_t buf[READ_BUF_LEN];
GIOStatus status;
gsize bytes_read;
len = sizeof(buf);
if (len > s->max_size) {
len = s->max_size;
}
if (len == 0) {
return TRUE;
}
status = g_io_channel_read_chars(chan, (gchar *)buf,
len, &bytes_read, NULL);
if (status == G_IO_STATUS_EOF) {
if (s->fd_in_tag) {
g_source_remove(s->fd_in_tag);
s->fd_in_tag = 0;
}
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
return FALSE;
}
if (status == G_IO_STATUS_NORMAL) {
qemu_chr_be_write(chr, buf, bytes_read);
}
return TRUE;
}
| 1threat |
How To Setup Contact Form in Wordpress : I am new to WordPress and PHP. I am creating website and now i want to setup the contact form in it.
I just want to set only functionality of contact form...i create a form using bootstrap which i don't want to change it. it is a requirements!
So i want to get your help in like when the user fill the contact-form. I get the email.The basic requirement is to recieve email using from that contact form. I want to get this using my form. Kindly need help in this. | 0debug |
static void virtio_pci_device_plugged(DeviceState *d)
{
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
VirtioBusState *bus = &proxy->bus;
uint8_t *config;
uint32_t size;
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
config = proxy->pci_dev.config;
if (proxy->class_code) {
pci_config_set_class(config, proxy->class_code);
}
pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID,
pci_get_word(config + PCI_VENDOR_ID));
pci_set_word(config + PCI_SUBSYSTEM_ID, virtio_bus_get_vdev_id(bus));
config[PCI_INTERRUPT_PIN] = 1;
if (proxy->nvectors &&
msix_init_exclusive_bar(&proxy->pci_dev, proxy->nvectors, 1)) {
error_report("unable to init msix vectors to %" PRIu32,
proxy->nvectors);
proxy->nvectors = 0;
}
proxy->pci_dev.config_write = virtio_write_config;
size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev)
+ virtio_bus_get_vdev_config_len(bus);
if (size & (size - 1)) {
size = 1 << qemu_fls(size);
}
memory_region_init_io(&proxy->bar, OBJECT(proxy), &virtio_pci_config_ops,
proxy, "virtio-pci", size);
pci_register_bar(&proxy->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO,
&proxy->bar);
if (!kvm_has_many_ioeventfds()) {
proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
}
virtio_add_feature(&vdev->host_features, VIRTIO_F_BAD_FEATURE);
}
| 1threat |
static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid,
uint64_t pictx, bool bsr)
{
XHCISlot *slot;
USBPort *uport;
USBDevice *dev;
dma_addr_t ictx, octx, dcbaap;
uint64_t poctx;
uint32_t ictl_ctx[2];
uint32_t slot_ctx[4];
uint32_t ep0_ctx[5];
int i;
TRBCCode res;
assert(slotid >= 1 && slotid <= xhci->numslots);
dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high);
poctx = ldq_le_pci_dma(PCI_DEVICE(xhci), dcbaap + 8 * slotid);
ictx = xhci_mask64(pictx);
octx = xhci_mask64(poctx);
DPRINTF("xhci: input context at "DMA_ADDR_FMT"\n", ictx);
DPRINTF("xhci: output context at "DMA_ADDR_FMT"\n", octx);
xhci_dma_read_u32s(xhci, ictx, ictl_ctx, sizeof(ictl_ctx));
if (ictl_ctx[0] != 0x0 || ictl_ctx[1] != 0x3) {
fprintf(stderr, "xhci: invalid input context control %08x %08x\n",
ictl_ctx[0], ictl_ctx[1]);
return CC_TRB_ERROR;
}
xhci_dma_read_u32s(xhci, ictx+32, slot_ctx, sizeof(slot_ctx));
xhci_dma_read_u32s(xhci, ictx+64, ep0_ctx, sizeof(ep0_ctx));
DPRINTF("xhci: input slot context: %08x %08x %08x %08x\n",
slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]);
DPRINTF("xhci: input ep0 context: %08x %08x %08x %08x %08x\n",
ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]);
uport = xhci_lookup_uport(xhci, slot_ctx);
if (uport == NULL) {
fprintf(stderr, "xhci: port not found\n");
return CC_TRB_ERROR;
}
trace_usb_xhci_slot_address(slotid, uport->path);
dev = uport->dev;
if (!dev) {
fprintf(stderr, "xhci: port %s not connected\n", uport->path);
return CC_USB_TRANSACTION_ERROR;
}
for (i = 0; i < xhci->numslots; i++) {
if (i == slotid-1) {
continue;
}
if (xhci->slots[i].uport == uport) {
fprintf(stderr, "xhci: port %s already assigned to slot %d\n",
uport->path, i+1);
return CC_TRB_ERROR;
}
}
slot = &xhci->slots[slotid-1];
slot->uport = uport;
slot->ctx = octx;
if (bsr) {
slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT;
} else {
USBPacket p;
uint8_t buf[1];
slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid;
usb_device_reset(dev);
memset(&p, 0, sizeof(p));
usb_packet_addbuf(&p, buf, sizeof(buf));
usb_packet_setup(&p, USB_TOKEN_OUT,
usb_ep_get(dev, USB_TOKEN_OUT, 0), 0,
0, false, false);
usb_device_handle_control(dev, &p,
DeviceOutRequest | USB_REQ_SET_ADDRESS,
slotid, 0, 0, NULL);
assert(p.status != USB_RET_ASYNC);
}
res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx);
DPRINTF("xhci: output slot context: %08x %08x %08x %08x\n",
slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]);
DPRINTF("xhci: output ep0 context: %08x %08x %08x %08x %08x\n",
ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]);
xhci_dma_write_u32s(xhci, octx, slot_ctx, sizeof(slot_ctx));
xhci_dma_write_u32s(xhci, octx+32, ep0_ctx, sizeof(ep0_ctx));
xhci->slots[slotid-1].addressed = 1;
return res;
}
| 1threat |
please help to explain the output of this c program : <p>After executing i am getting the output as 12 6 11. please explain how this is possible</p>
<pre><code>#include<stdio.h>
#define MAN(x,y) (x)>(y)?(x):(y)
int main()
{
int i = 10,j = 5,k = 0;
k = MAN(i++,++j);
printf("%d %d %d", i, j, k);
return 0;
}
</code></pre>
| 0debug |
Fastest way to solve the divisibility of numbers : <p>I have a program in which in which 4 numbers are input n,a,b,c</p>
<p>how many number exists which are less than or equal to n and are divisible by a ,b or c .</p>
<p>Sample input case -
15 2 3 5
output
11</p>
<p>Here n = 15 , a= 2, b=3,c = 5 The number which are divisible by a ,b, or c are 2,3,4,5,6,8,9,10,12,14,15 i.e 11 numbers , so output is 11</p>
<p>I have tried with this solution but the time is exceeding</p>
<pre><code>#include<stdio.h>
long long divisibilty (long long a, long long c, long long b, long long n ) {
long long temp, min,count = 0,i;
temp = (a < b) ? a : b;
min = (c < temp) ? c : temp;
for(i=min;i<=n;i++){
if( (i % a == 0) || (i % b == 0) || (i % c == 0) ){
count++;
}
}
return count;
}
int main() {
int t_i;
long long n;
scanf("%lld", &n);
long long a;
scanf("%lld", &a);
long long b;
scanf("%lld", &b);
long long c;
scanf("%lld", &c);
long long out_ = divisibilty(a, c, b, n);
printf("%lld", out_);
}
</code></pre>
<p>Can anyone help me with a better solution</p>
| 0debug |
static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs,
BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
QEMUIOVector *qiov, int flags)
{
BlockDriver *drv = bs->drv;
bool waited;
int ret;
int64_t sector_num = offset >> BDRV_SECTOR_BITS;
unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS;
assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 0);
assert(!qiov || bytes == qiov->size);
waited = wait_serialising_requests(req);
assert(!waited || !req->serialising);
assert(req->overlap_offset <= offset);
assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
if (!ret && bs->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF &&
!(flags & BDRV_REQ_ZERO_WRITE) && drv->bdrv_co_write_zeroes &&
qemu_iovec_is_zero(qiov)) {
flags |= BDRV_REQ_ZERO_WRITE;
if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
flags |= BDRV_REQ_MAY_UNMAP;
}
}
if (ret < 0) {
} else if (flags & BDRV_REQ_ZERO_WRITE) {
BLKDBG_EVENT(bs, BLKDBG_PWRITEV_ZERO);
ret = bdrv_co_do_write_zeroes(bs, sector_num, nb_sectors, flags);
} else {
BLKDBG_EVENT(bs, BLKDBG_PWRITEV);
ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov);
}
BLKDBG_EVENT(bs, BLKDBG_PWRITEV_DONE);
if (ret == 0 && !bs->enable_write_cache) {
ret = bdrv_co_flush(bs);
}
bdrv_set_dirty(bs, sector_num, nb_sectors);
if (bs->stats.wr_highest_sector < sector_num + nb_sectors - 1) {
bs->stats.wr_highest_sector = sector_num + nb_sectors - 1;
}
if (bs->growable && ret >= 0) {
bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
}
return ret;
}
| 1threat |
static void arm_cpu_initfn(Object *obj)
{
CPUState *cs = CPU(obj);
ARMCPU *cpu = ARM_CPU(obj);
static bool inited;
cs->env_ptr = &cpu->env;
cpu_exec_init(&cpu->env);
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
g_free, g_free);
#ifndef CONFIG_USER_ONLY
if (kvm_enabled()) {
qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 4);
} else {
qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 4);
}
cpu->gt_timer[GTIMER_PHYS] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE,
arm_gt_ptimer_cb, cpu);
cpu->gt_timer[GTIMER_VIRT] = timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCALE,
arm_gt_vtimer_cb, cpu);
qdev_init_gpio_out(DEVICE(cpu), cpu->gt_timer_outputs,
ARRAY_SIZE(cpu->gt_timer_outputs));
#endif
cpu->dtb_compatible = "qemu,unknown";
cpu->psci_version = 1;
cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
if (tcg_enabled() && !inited) {
inited = true;
arm_translate_init();
}
}
| 1threat |
bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie)
{
assert(cookie->type < BDRV_MAX_IOTYPE);
bs->stats.nr_bytes[cookie->type] += cookie->bytes;
bs->stats.nr_ops[cookie->type]++;
bs->stats.total_time_ns[cookie->type] += get_clock() -
cookie->start_time_ns;
}
| 1threat |
c++ read files from folder and save it to vector of strings : I am trying to read textfiles from an folder and save the names to a vector of strings. This is my code by now. I can compile and run it, but it is not saving my files to the vector.
int main(){
Data Dataset;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
// Find the first file in the directory.
hFind = FindFirstFile(LPCTSTR("C:\\Users\\bla\\Desktop\\c++\\data\\*"), &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) {
cout<<"ERROR"<<endl;
}
else{
while (FindNextFile(hFind, &FindFileData) != 0) {
if(FindFileData.cFileName=="*.txt")
{
Dataset.name.push_back(FindFileData.cFileName);
}
cout<<FindFileData.cFileName<<endl;
}
FindClose(hFind);
}
for(int i=0; i<Dataset.name.size(); i++){
cout<<Dataset.name[i]<<endl;
}
}
Hope you can help me.
Thanks a lot.
Peace | 0debug |
Android Instant App : Default Activity not found : <p>This seems to be manifest merging error. I'm trying to port existing code to instant app module. What I've tried is :</p>
<ol>
<li>Changed main app module to baseFeatureModule. </li>
<li>Created a new module completeApp.</li>
<li><p>Emptied completeAppModule's Manifest :
</p>
<p></p></li>
<li><p>added implementation project entry in completeAppModule </p>
<p>implementation project (":udofy")</p></li>
<li><p>Added these entries in base module :</p>
<p>baseFeature true in android block</p>
<p>application project (":fullModule") in dependencies</p></li>
</ol>
<p>I've tried rebuilding/ invalidate cache and restart/ Restarting studio but no help. Can anybody help me out here?</p>
| 0debug |
void ff_biweight_h264_pixels4_8_msa(uint8_t *dst, uint8_t *src,
int stride, int height,
int log2_denom, int weight_dst,
int weight_src, int offset)
{
avc_biwgt_4width_msa(src, stride,
dst, stride,
height, log2_denom,
weight_src, weight_dst, offset);
}
| 1threat |
static int milkymist_softusb_init(SysBusDevice *dev)
{
MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev);
sysbus_init_irq(dev, &s->irq);
memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s,
"milkymist-softusb", R_MAX * 4);
sysbus_init_mmio(dev, &s->regs_region);
memory_region_init_ram(&s->pmem, OBJECT(s), "milkymist-softusb.pmem",
s->pmem_size, &error_abort);
vmstate_register_ram_global(&s->pmem);
s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem);
sysbus_init_mmio(dev, &s->pmem);
memory_region_init_ram(&s->dmem, OBJECT(s), "milkymist-softusb.dmem",
s->dmem_size, &error_abort);
vmstate_register_ram_global(&s->dmem);
s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem);
sysbus_init_mmio(dev, &s->dmem);
hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain);
hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain);
return 0;
}
| 1threat |
Module compiled with Swift 2.3 cannot be imported in Swift 3.0 : <p>i add Facebook SDK (Swift) to my project.
And now i update Xcode 8 and Swift 3.
I have error in build time </p>
<pre><code>Module compiled with Swift 2.3 cannot be imported in Swift 3.0
</code></pre>
<p>It is very strange that is not supported.
Has anyone had similar problems?</p>
| 0debug |
C- how to read input from stdin until newline character using read()? : <p>Basically I want to use the read() function to read in a typed message from STDIN, but I want to quit the message by typing just the enter key instead of using CTRL + D. What's the best way to do this? </p>
| 0debug |
Exception occurs when trying to deserialize using Json.Net : <p>I am trying to deserialize the following json using Json.Net into C# classes as defined below. I am having this exception:</p>
<blockquote>
<p>Newtonsoft.Json.JsonSerializationException: 'Could not create an
instance of type Viewer.ShapeDto. Type is an interface or abstract
class and cannot be instantiated. Path '[0].type', line 3, position
13.'</p>
</blockquote>
<pre><code>[
{
"type":"line",
"a":"-1,5; 3,4",
"b":"2,2; 5,7",
"color":"127; 255; 255; 255",
"lineType":"solid"
},
{
"type":"circle",
"center":"0; 0",
"radius":15.0,
"filled":false,
"color":"127; 255; 0; 0",
"lineType":"dot"
}
]
public abstract class ShapeDto
{
[JsonProperty(PropertyName = "type")]
public abstract string Type { get; }
[JsonProperty(PropertyName = "color")]
public string Color { get; set; }
[JsonProperty(PropertyName = "lineType")]
public string LineType { get; set; }
}
public sealed class LineDto : ShapeDto
{
public override string Type => "line";
[JsonProperty(PropertyName = "a")]
public string A { get; set; }
[JsonProperty(PropertyName = "b")]
public string B { get; set; }
}
public sealed class CircleDto : ShapeDto
{
public override string Type => "circle";
[JsonProperty(PropertyName = "center")]
public string C { get; set; }
[JsonProperty(PropertyName = "radius")]
public double R { get; set; }
[JsonProperty(PropertyName = "filled")]
public bool Filled { get; set; }
}
var settings = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All};
var shapes = JsonConvert.DeserializeObject<IList<ShapeDto>>(json, settings);
</code></pre>
| 0debug |
what does x = tf.placeholder(tf.float32, [None, 784]) means? : <p>I know basic use for tf.placeholder:</p>
<pre><code>x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)
with tf.Session() as sess:
print(sess.run(y)) # ERROR: will fail because x was not fed.
rand_array = np.random.rand(1024, 1024)
print(sess.run(y, feed_dict={x: rand_array})) # Will succeed.
</code></pre>
<p>I know the second parameter is about <strong>shape</strong>. However I don't know what is that mean when the first one is <strong>None</strong> in the shape. ex:[None,784].</p>
| 0debug |
php : replicate the excel price() function in php : <p>I have really been struggling replicating the excel price() function in php.</p>
<p>Has anyone had any experience doing this before? or is it available in phpexcel?</p>
| 0debug |
def check_monthnumb(monthname2):
if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"):
return True
else:
return False | 0debug |
replace link url in body of e-mail sending per application java : I have application send e-mail to customer and I use **javax.mail.Transport** Class to do this. I want include an URL link in body of e-mail but I prefer mask the link with sentence for example "click here" instead of "https://link.com" .
can any one help me
thanks a lot . | 0debug |
how to to change value every looop : How to loop and change everytime value
example run for loop 7 times for inserting day names to database
for ($t = 0 ; $t < 7 $t++){
$defaultValues = "INSERT INTO workingDays (bussinessID, day, workingHours) VALUES (?,?,?)";
$pdo->prepare($defaultValues)->execute([$bussinessID, $dayNames, $hours]);
}
So it inserts to database like this:
Default values:
>BussinessID: 1, Day: Monday, workingHours: 8
>BussinessID: 1, Day: Tuesday, workingHours: 8
>BussinessID: 1, Day: Wednesday, workingHours: 8
>BussinessID: 1, Day: Thursday, workingHours: 8
>BussinessID: 1, Day: Friday, workingHours: 8
>BussinessID: 1, Day: Saturday, workingHours: 8
>BussinessID: 1, Day: Sunday, workingHours: 8 | 0debug |
void s390x_cpu_debug_excp_handler(CPUState *cs)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
CPUWatchpoint *wp_hit = cs->watchpoint_hit;
if (wp_hit && wp_hit->flags & BP_CPU) {
cs->watchpoint_hit = NULL;
env->per_address = env->psw.addr;
env->per_perc_atmid |= PER_CODE_EVENT_STORE | get_per_atmid(env);
env->per_perc_atmid |= env->psw.mask & (PSW_MASK_ASC) >> 46;
cpu_watchpoint_remove_all(cs, BP_CPU);
cpu_resume_from_signal(cs, NULL);
}
}
| 1threat |
How do I create an observable of an array from an array of observables? : <p>I have an array of <code>Thing</code> objects that I want to convert to <code>ConvertedThing</code> objects, using an asynchronous function that returns <code>Observable<ConvertedThing></code>.</p>
<p>I'd like to create an <code>Observable<[ConvertedThing]></code> that emits one value when all the conversions have completed.</p>
<p>How can this be accomplished? Any help much appreciated!</p>
| 0debug |
JAVA Code snippet: Output Explanation : Need Explanation of this Code :
public static void main(String[] args) { <p>
int a=010; <p>
int b=07; <p>
System.out.println(a); <p>
System.out.println(b); <p>
}
<p>
**OutPut** : <p> 8 <p> 7 | 0debug |
Push Notifications not being received on iOS 10, but working on iOS 9 and before : <p>I have several apps that were written in Swift 2.2, compiled with Xcode 7.3 and is live on the App Store. The apps utilize Push Notifications and is working fine in iOS 9.3 and earlier.</p>
<p>On devices that have been upgraded to iOS 10, however, my apps don't receive any Push Notifications. Devices that are still running iOS 9 are still receiving notifications.</p>
<p>Thinking it might be a certificate or entitlement issue, I have tried the following:
Upgraded one of my apps to Swift 2.3, added the APS Environment Entitlement and compiled it in Xcode 8 but this made no difference.</p>
<p>In my AppDelegate I still have the existing methods to register for push notifications that includes:</p>
<pre><code>let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories:nil)
application.registerUserNotificationSettings(notificationSettings)
</code></pre>
<p>This registration seems to be successful even on iOS 10 since <em>Application didRegisterForRemoteNotificationsWithDeviceToken</em> is then called, so I am receiving a token from APNS.</p>
<p>The problem is that when I send a push notification to this device, <em>Application didReceiveRemoteNotification</em> is never called.</p>
<p>Now, <a href="http://cleanswifter.com/ios-10-local-notifications/">here</a> it is said that the methods on UIApplicationDelegate is deprecated on iOS 10 and I should implement userNotificationCenter(<em>:didReceive:withCompletionHandler:) and userNotificationCenter(</em>:willPresent:withCompletionHandler:)</p>
<p>The problem is that I am not ONLY targeting iOS 10. I still need the app to work on iOS 8 and 9 so I doubt that it's the correct approach to implement those methods.</p>
<p>How do I get push notifications for an existing app to continue working on devices that have been upgraded to iOS 10? Do I need to rewrite code? Do I just need to update some certificates or entitlements and recompile in Xcode 8 with some "new" settings?</p>
| 0debug |
how to copy file fron one location to another location using java in dynamically : we are trying to copy one file to another location. But we succeed all files move to one location to another but i want to copy only particular file into one location to anothier location.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
import java.io.File;
public class fileTranfer {
public static void main(String[] args) {
File sourceFolder = new File("C:/offcial/BPM/Veriflow");
File destinationFolder = new File("C:/offcial/BPM/Veriflow2");
if (!destinationFolder.exists())
{
destinationFolder.mkdirs();
}
// Check weather source exists and it is folder.
if (sourceFolder.exists() && sourceFolder.isDirectory())
{
// Get list of the files and iterate over them
File[] listOfFiles = sourceFolder.listFiles();
if (listOfFiles != null)
{
for (File child : listOfFiles )
{
// Move files to destination folder
child.renameTo(new File(destinationFolder + "\\" + child.getName()));
}
}
System.out.println(destinationFolder + " files transfered.");
}
else
{
System.out.println(sourceFolder + " Folder does not exists");
}
}
}
<!-- end snippet -->
| 0debug |
static int hls_read(URLContext *h, uint8_t *buf, int size)
{
HLSContext *s = h->priv_data;
const char *url;
int ret;
int64_t reload_interval;
start:
if (s->seg_hd) {
ret = ffurl_read(s->seg_hd, buf, size);
if (ret > 0)
return ret;
}
if (s->seg_hd) {
ffurl_close(s->seg_hd);
s->seg_hd = NULL;
s->cur_seq_no++;
}
reload_interval = s->n_segments > 0 ?
s->segments[s->n_segments - 1]->duration :
s->target_duration;
reload_interval *= 1000000;
retry:
if (!s->finished) {
int64_t now = av_gettime();
if (now - s->last_load_time >= reload_interval) {
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
return ret;
reload_interval = s->target_duration * 500000;
}
}
if (s->cur_seq_no < s->start_seq_no) {
av_log(h, AV_LOG_WARNING,
"skipping %d segments ahead, expired from playlist\n",
s->start_seq_no - s->cur_seq_no);
s->cur_seq_no = s->start_seq_no;
}
if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
if (s->finished)
return AVERROR_EOF;
while (av_gettime() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_usleep(100*1000);
}
goto retry;
}
url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ,
&h->interrupt_callback, NULL);
if (ret < 0) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_log(h, AV_LOG_WARNING, "Unable to open %s\n", url);
s->cur_seq_no++;
goto retry;
}
goto start;
}
| 1threat |
Flutter Outline View - "Nothing to show" : <p>Hi has anyone already tried the new "Flutter Outline"-View? </p>
<p>I only see "Nothing to show" what I do wrong? Has anyone an idea?</p>
<p><a href="https://i.stack.imgur.com/lMidQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lMidQ.png" alt="enter image description here"></a></p>
| 0debug |
Program won't run? : <p>I am trying to make this program work, with no success. The program involves arithmetic with float types, and consists of the function temperature(), to convert Fahrenheit to Celsius. The function gets the input from a <code>for</code> loop, but when I execute it, I only get the first conversion. What am I doing wrong? Here is the code:</p>
<pre><code>#include<stdio.h>
float temperature(int);
int main() {
int i;
for (i = 0; i <= 300; i = i + 20)
printf("%3d\t%6.2f\n", i, temperature(i));
return 0;
}
float temperature(int m) {
float low, up, step, f, t;
float j = 5.0/9.0;
for (f = low; f <= up; f = f + step)
t = j * (f - 32.0);
return t;
}
</code></pre>
| 0debug |
Folder in .gitignore is still in repo : <p>I have added a folder in my .gitignore file. But when I pushed to the repo it was still being pushed. my folder structure is:</p>
<pre><code>UI/node_modules
</code></pre>
<p>In the .gitignore I have added the following:</p>
<pre><code>/UI/node_modules
/UI/bin
</code></pre>
<p>Is there anything I am doing wrong? gitignore file sits at the same level as the UI folder</p>
| 0debug |
static int spapr_msicfg_find(sPAPRPHBState *phb, uint32_t config_addr,
bool alloc_new)
{
int i;
for (i = 0; i < SPAPR_MSIX_MAX_DEVS; ++i) {
if (!phb->msi_table[i].nvec) {
break;
}
if (phb->msi_table[i].config_addr == config_addr) {
return i;
}
}
if ((i < SPAPR_MSIX_MAX_DEVS) && alloc_new) {
trace_spapr_pci_msi("Allocating new MSI config", i, config_addr);
return i;
}
return -1;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.